Announcement

Collapse
No announcement yet.

Do Until Empty Cell or "Find" is not found

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Do Until Empty Cell or "Find" is not found

    I'm trying to have this loop until and empty cell is found or until it cannot find the word I'm searching for anymore. It works fine by itself like this:

    Code:
    objExcel.Columns("A:A").Find("test2").Entirerow.Delete
    objExcel.Columns("A:A").FindNext.Entirerow.Delete
    But when I try to loop it nothing happens...

    Code:
    Do Until objExcel.ActiveCell = VbEmpty
    objExcel.Columns("A:A").Find("test2").Entirerow.Delete
    objExcel.Columns("A:A").FindNext.Entirerow.Delete
    Loop
    What am I doing wrong?

  • #2
    Re: Do Until Empty Cell or "Find" is not found

    I got it!

    Code:
    intRow = 1
    Do Until (objExcel.Cells(intRow,1).Value) = ""
    objExcel.Cells(intRow,1).Find("test2").Entirerow.Delete
    intRow = intRow + 1
    Loop

    Comment


    • #3
      Re: Do Until Empty Cell or "Find" is not found

      =vbEmpty is zero and has 0 as value
      =Empty is empty the same as ""

      Or you can use the IsEmpty function:
      Do Until IsEmpty(.....)
      <...>
      Loop

      -or-

      Do While Not IsEmpty(.....)
      <...>
      Loop


      \Rems

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment

      Working...
      X