Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Count Rows with VBA

Perfect, just what I was looking for, thank you bot

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

Reply
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
Count all rows in column with data, Except rows 1-5 Gregory Day Excel Worksheet Functions 4 March 27th 08 02:58 PM
match week, count rows, sum rows? earls Excel Worksheet Functions 2 January 5th 07 02:34 AM
Count number of rows, where non relevant rows are hidden Pieter Excel Discussion (Misc queries) 2 November 8th 06 12:24 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM
Why does rngDataSource.Rows.Count = 65536 when worksheet Rows=95? [email protected] Excel Discussion (Misc queries) 12 July 22nd 05 12:50 PM


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

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"