Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default best way to get reference to all used cells

I was using the macro recorder to see how to use the range.sort
function. When I did, I got something like:

Range("A1:J235").Sort Key1:=Range("A1"), Order1:=xlAscending

I should always know the number of columns but the number of rows will
vary. What's the best in code of coming up the "A1:J235"?

Thanks,
Woody

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default best way to get reference to all used cells

Hi,

lastrow=Cells(rows.count,"A").end(xlup).row

Range("A1:J" & lastrow).Sort Key1:=Range("A1"), Order1:=xlAscending

HTH

"sugargenius" wrote:

I was using the macro recorder to see how to use the range.sort
function. When I did, I got something like:

Range("A1:J235").Sort Key1:=Range("A1"), Order1:=xlAscending

I should always know the number of columns but the number of rows will
vary. What's the best in code of coming up the "A1:J235"?

Thanks,
Woody


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default best way to get reference to all used cells

thanks, I forgot you can concatenate strings and numbers without any
effort.

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
Formulas that reference cells that reference another cell Andrea Excel Discussion (Misc queries) 7 October 19th 06 08:14 AM
Compare two cells from reference cells Mike K Excel Worksheet Functions 2 November 26th 05 02:07 PM
best way to get reference to all used cells sugargenius Excel Worksheet Functions 1 November 11th 05 12:49 PM
How do I reference the last 3 cells in a row as cells are added Still Learning Excel Worksheet Functions 6 January 8th 05 05:10 PM


All times are GMT +1. The time now is 08:57 AM.

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

About Us

"It's about Microsoft Excel"