|
Sub 得到选中行的行号()
Dim cel As Range, d, arr
Set d = CreateObject("Scripting.Dictionary")
For Each cel In Selection
d(cel.Row) = ""
Next
arr = d.keys
MsgBox Join(arr, ",")
End Sub
以上是论坛里蓝老师写的,得到选中行的行号。
Sub 隐藏第3和5列没数据的列()
b = Cells.Find("*", , , , 2, 2).Column '所有行中有数据的最大列号
For i = 1 To b
If Cells(3, i) = "" And Cells(5, i) = "" Then
Columns(i).EntireColumn.Hidden = True
End If
Next
End Sub
这是一个简单的隐藏第3和5行都空白列的代码
我实际要判定的不是第3行和第5行,而是当前选中的行,即蓝老师代码arr 中的行,也就是 Cells(arr (1,1), i) = "" And Cells(arr (1,2), i) = "" And Cells(arr (1,3), i) = ""……………………
但语法不对,该怎么表达啊,谢谢了
|
|