View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel[_332_] joel[_332_] is offline
external usenet poster
 
Posts: 1
Default get number of rows


Since you didn't give anything about your data structure I wrote this
macro that will handle any case. I don't know which columns contain
data. this macro only looks at the last row of data and not for blanks
in the middle of the data. You request for number of USED ROWS which
could mean a few different things.


Sub BlankRows()

Sht1LastRow = 0
Sht2LastRow = 0
For ColCount = 1 To Columns.Count
LastRow = Sheets("Sheet1").Cells(Rows.Count,
ColCount).End(xlUp).Row
If LastRow Sht1LastRow Then
Sht1LastRow = LastRow
End If

LastRow = Sheets("Sheet2").Cells(Rows.Count,
ColCount).End(xlUp).Row
If LastRow Sht2LastRow Then
Sht2LastRow = LastRow
End If

Next ColCount

If Sht1LastRow < Sht2LastRow Then
If Sht1LastRow Sht2LastRow Then
MsgBox ("Sheet2 has (blank) number")
Else
MsgBox ("Sheet1 has (blank) number")
End If

Response = MsgBox("Do you want to proceed", vbYesNo)
If Response = vbNo Then Exit Sub
End If

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=161620

Microsoft Office Help