编程选择每列当中首尾不空(中间可空)的部分?如图

来源:百度知道 编辑:UC知道 时间:2024/05/31 09:26:16
3
1 5
2 4
6
即实现单元格内容为[1 2] [3 4] [5 6]之间的选择?

我的代码不可以,For ii = 1 To 600
If ActiveSheet.Cells(ii, jj) <> "" Then
frt = ActiveCell.Row
Exit For
End If
Next ii

For ii = 600 To 1
If ActiveSheet.Cells(ii, jj) <> "" Then
lst = ActiveCell.Row
Exit For
End If
Next ii
请求高手帮助!非常感谢!

可以看出你是在excel里用vba了

ActiveCell.SpecialCells(xlLastCell).Select
估计这一句是你最想要的

ActiveCell.SpecialCells(xlLastCell).Select '焦点定位到表格的已使用的最后一格单元格
Row = ActiveCell.Row '表的总行数
col = ActiveCell.Column '表的总烈数
Dim temprow
For i = 1 To col
temprow = 1
Do While IsEmpty(Cells(temprow, i).Value2) '如果这个单元格中没有内容
temprow = temprow + 1
Loop '定位到非空单元格
Next
实在不知道你想要什么,希望这些对你有些帮助

For ii = 1 To 600
For jj= 600 To 1 step -1
If ActiveSheet.Cells(ii, jj) <> "" Then
frt = ActiveCell.Row
Exit For
End If
Next jj
Next ii

Private Sub CommandButton1_Click()
Dim i As Integer
Dim S As Double
S = 1
For i = 1 To 49
S = S + Val(i / (i + 1))
Next
Debug.Print S
End Sub