vba excel中 如果A列偶数行有为0的,则隐藏这行和上面一行(A2为0隐藏1、2行。。)
1个回答
展开全部
Sub test()
Dim i%
For i = 1 To [a65536].End(xlUp).Row
If i Mod 2 = 0 And Cells(i, 1) = 0 Then
Rows(i - 1).Hidden = True
Rows(i).Hidden = True
End If
Next i
End Sub
Dim i%
For i = 1 To [a65536].End(xlUp).Row
If i Mod 2 = 0 And Cells(i, 1) = 0 Then
Rows(i - 1).Hidden = True
Rows(i).Hidden = True
End If
Next i
End Sub
追问
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sub test()
Dim i%
For i = 1 To [a65536].End(xlUp).Row
If i Mod 2 = 0 And Cells(i, 1) = 0 Then
Rows(i - 1).Hidden = True
Rows(i).Hidden = True
End If
Next i
End Sub
End Sub
缺少END SUB
追答
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i%
Rows("1:65536").Hidden = False
For i = 1 To [a65536].End(xlUp).Row
If i Mod 2 = 0 And Cells(i, 1) = 0 Then
Range(Rows(i - 1), Rows(i)).Hidden = True
End If
Next i
End Sub
这样就可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询