LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting a number of rows based on the number of columns filled bytext values zorakramone Excel Programming 4 August 3rd 09 08:21 AM
Fill Cells with same number in three rows then skip to next number Tracy Excel Worksheet Functions 2 November 7th 08 03:12 PM
Get number of rows that data uses, including blank rows Denham Coote Excel Discussion (Misc queries) 5 August 22nd 06 02:10 PM
Get number of rows that data takes up, including blank rows Denham Coote Excel Worksheet Functions 2 August 21st 06 09:18 AM
flexible paste rows function that inserts the right number of rows marika1981 Excel Discussion (Misc queries) 1 February 18th 05 02:40 AM


All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"