Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Last Active Row

I want to loop through each row, doing verious things, and
I need to stop at the last active row. I never know
exactly how many rows are active.

What VB reference do I use to get that number:

For i = 1 to ??????
Do Stuff
next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Last Active Row

If you have data in the first row

For I = 1 To ActiveSheet.UsedRange.Rows.Count

Or if you only test data in one column

For I = 1 To ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Bill Sturdevant" wrote in message ...
I want to loop through each row, doing verious things, and
I need to stop at the last active row. I never know
exactly how many rows are active.

What VB reference do I use to get that number:

For i = 1 to ??????
Do Stuff
next i



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Last Active Row

Bill try something like this.

Dim rng as Long
Set rng = Worksheets("sheet1").Cells(1,1).CurrentRegion

for i = 1 to rng.rows.count
'''' Do something '''
next i

HTH


Charle

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Last Active Row

the following works. don't know if it's elegant or not

Set dataSheet = ActiveShee
totalrows = dataSheet.UsedRange.Rows.Count
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
Row select mode to highlight active row of active cell Bart Fay[_2_] Excel Discussion (Misc queries) 0 May 11th 10 09:34 PM
referring to formula in a non active cell from active cell nickname Excel Discussion (Misc queries) 1 June 21st 07 12:11 PM
HOW TO COPY 480 ACTIVE E-MAIL ADDRESSES CLM "G" ON AN ACTIVE EXCE. ragman10 Excel Discussion (Misc queries) 1 December 13th 04 11:52 PM
Active X njavdan Excel Programming 3 October 23rd 03 04:43 PM
Last Active Eric[_8_] Excel Programming 1 July 23rd 03 02:49 PM


All times are GMT +1. The time now is 07:37 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"