View Single Post
  #5   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Trying to find the fourth blank cell in a column

On Sun, 27 Apr 2008 17:10:55 +0100, "teepee" wrote:

Hello

I'm trying to find th fourth blank cell in a column and select a range based
on it. Should be simple but for some reason I can't makeit work. Anyone tell
me what I'm doing wrong? I'd be most grateful.

For background, I have some data followed by two blank cells, followed by
more data, folowed by a blank cell, followed by more data followed by
another blank cell, followed by more data followed by blank cells to the
end. It's the start of these final blanks I'm trying to find
programatically.


It occurs to me you might want to be searching for cells that display a blank,
and not cells that are actually empty. If so, something like:

========================
Sub GetNullStringCells()
Dim BlankCells(0 To 3) As Range
Dim rg As Range
Dim i As Long
Set rg = Range("A:A")
Set BlankCells(0) = rg.Find("", LookIn:=xlValues)
For i = 1 To 3
Set BlankCells(i) = rg.FindNext(BlankCells(i - 1))
Next i
For i = 0 To 3
Debug.Print BlankCells(i).Address
Next i
End Sub
============================
--ron