Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Using last row in macros

I want to be able to select the last row which contains data and use the row
number in a macro to select all the cells in a column from the top to the
last row. The number of rows varies each time the macro is run.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Using last row in macros

Number = ActiveSheet.UsedRange.SpecialCells(xlLastCell).Row

"robertlewis" wrote:

I want to be able to select the last row which contains data and use the row
number in a macro to select all the cells in a column from the top to the
last row. The number of rows varies each time the macro is run.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Using last row in macros


lr=cells(rows.count,"a").end(xlup).row
range(cells(1,"a"),cells(lr,"a")).copy range("b3")

You rarely need to select but if you insist
lr=cells(rows.count,"a").end(xlup).row
range(cells(1,"a"),cells(lr,"a")).select

--
Don Guillett
SalesAid Software

"robertlewis" wrote in message
...
I want to be able to select the last row which contains data and use the
row
number in a macro to select all the cells in a column from the top to the
last row. The number of rows varies each time the macro is run.



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
Can't Open Excel Files with Macros Charles A C Excel Discussion (Misc queries) 1 January 9th 07 03:52 AM
Macros Don't Show On Commands List and 'Normal.dot' SV Excel Worksheet Functions 3 December 13th 06 07:23 PM
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
how do I run excel 4.0 macros on excel 2000 RodolfoDallas Excel Discussion (Misc queries) 1 March 12th 06 03:14 AM
Excel crashes while opening excel file imbeddied with macros ct2147 Excel Discussion (Misc queries) 0 December 30th 05 09:05 PM


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