-1

hi I have this code below

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

Its works fine but I would like the Macros to End when it finds an Entire blank row in the range A1:Z50 . This will save a lot of my time. As it will not validate empty cell in this range.

Community
  • 1
  • 1

1 Answers1

0

Give this a try:

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
Gary's Student
  • 95,722
  • 10
  • 59
  • 99