View Single Post
  #2   Report Post  
Jim Cone
 
Posts: n/a
Default

Ryan,

I was doubtful that just knowing there was data would be enough...
So following is some code to cover several possibilities.
(you can understand how some of this works if you look up the terms
used in the help file - just stick the cursor in a word and press F1)
'------------------
Sub FindStuff()
Dim lngRw As Long
Dim lngCount As Long
Dim strBlanks As String
Dim strData As String

'Last row with data in Column A
lngRw = Cells(Rows.Count, 1).End(xlUp).Row

'Count of cells with data in Column A (below cell A4)
lngCount = WorksheetFunction.CountA(Range("A5", Cells(Rows.Count, 1)))

'Address of cells with blanks (below cell A4)
strBlanks = Range("A5", _
Cells(lngRw, 1)).SpecialCells(xlCellTypeBlanks).Address

'Address of cells with values (below cell A4)
strData = Range("A5", _
Cells(lngRw, 1)).SpecialCells(xlCellTypeConstants).Address

'Address of cells with formulas (below cell A4)
strData = strData & "," & Range("A5", _
Cells(lngRw, 1)).SpecialCells(xlCellTypeFormulas).Address

'Put it all together and display it
MsgBox "Last row is " & lngRw & vbCr & "Location of blank cells is " & _
strBlanks & vbCr & "Total cell count with data is " & _
lngCount & vbCr & "Location of cells with data is " & strData
End Sub
'-------------------------------

Regards,
Jim Cone
San Francisco, USA



"Ryan Cain" wrote in message
...
How do I find out how many rows have data in them starting with row 4 and
beyond? It's ok if I just know that column A has data in it.

I'm using VBA. I don't know how to use functions very well. But I know
visual basic some. So if you could give me some VBA code to do this, that
would be great. Thanks.