嗨,我有以下代码
Sub test2()
Dim c As Range
For Each c In Range("A1:Z50").Cells
c.Select
SendKeys "{F2}", True
SendKeys "{ENTER}", True
Next
End Sub
它的工作正常,但我希望Macros在找到A1:Z50范围内的整个空白行时结束。这将节省我很多时间。因为它不会验证此范围内的空单元格。
答案 0 :(得分:0)
尝试一下:
Sub test2()
Dim c As Range, ccheck As Range
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
For Each c In Range("A1:Z50")
Set ccheck = Intersect(c.EntireRow, Range("A:Z"))
If wf.CountA(ccheck) = 0 Then Exit Sub
c.Select
Application.SendKeys "{F2}", True
Application.SendKeys "{ENTER}", True
DoEvents
Next c
End Sub