ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count Rows with VBA (https://www.excelbanter.com/excel-programming/305345-count-rows-vba.html)

jdwhytie

Count Rows with VBA
 
I am trying to code some VBA for a spreadsheet. Not all th
spreadsheets I will be using it on are of exactly the same length, so
am trying to find a way to get a count of all of the rows that hav
information in them so I can use that to set up my references.

Is there a way to do this short of searching for an empty row? I wa
thinking there might be a property that would give me a row count bu
have been unable to find anything to do what I need.

Thanks
-Jak

--
Message posted from http://www.ExcelForum.com


Norman Jones

Count Rows with VBA
 
Hi Jake,

Using column A to establish the last row, try:

: Cells(Rows.Count, "A").End(xlUp).Row

---
Regards,
Norman



MsgBox Cells(Rows.Count, "A").End(xlUp).Address
"jdwhytie " wrote in message
...
I am trying to code some VBA for a spreadsheet. Not all the
spreadsheets I will be using it on are of exactly the same length, so I
am trying to find a way to get a count of all of the rows that have
information in them so I can use that to set up my references.

Is there a way to do this short of searching for an empty row? I was
thinking there might be a property that would give me a row count but
have been unable to find anything to do what I need.

Thanks
-Jake


---
Message posted from http://www.ExcelForum.com/




Chip Pearson

Count Rows with VBA
 
Jake,

There are a variety of ways to do this, depending on the
organization of your worksheet. For example,

Dim NumRows As Long
NumRows = Worksheets("Sheet1").UsedRange.Rows.Count
' or
NumRows =
Worksheets("Sheet1").Cells(Rows.Count,"A").End(xlU p).Row


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"jdwhytie " wrote in
message ...
I am trying to code some VBA for a spreadsheet. Not all the
spreadsheets I will be using it on are of exactly the same

length, so I
am trying to find a way to get a count of all of the rows that

have
information in them so I can use that to set up my references.

Is there a way to do this short of searching for an empty row?

I was
thinking there might be a property that would give me a row

count but
have been unable to find anything to do what I need.

Thanks
-Jake


---
Message posted from http://www.ExcelForum.com/




jdwhytie[_2_]

Count Rows with VBA
 
Perfect, just what I was looking for, thank you bot

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com