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

I am trying to sort a range in my worksheet.
I create a worksheet pulling data from other spreadsheets. I go through a
directory and advance rows by using x+1. At the the end I don't know how
many rows I have and I don't want to hard code it. How do I use a variable
in the Range expression.
I only know

Range("A6:AT255")

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Sort Selection

Range("A6:AT" & x)

0r
Range("A6:AT" & x + 1)

also

Range(cells(6,"A"),cells(x,"AT"))

or x + 1 of course.


--
Regards,
Tom Ogilvy

"ibbm" wrote:

I am trying to sort a range in my worksheet.
I create a worksheet pulling data from other spreadsheets. I go through a
directory and advance rows by using x+1. At the the end I don't know how
many rows I have and I don't want to hard code it. How do I use a variable
in the Range expression.
I only know

Range("A6:AT255")

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sort Selection

Can you pick out a column that always has data?

Dim LastRow as long

with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row

.range("a6:At" & lastrow).sort...

end with



ibbm wrote:

I am trying to sort a range in my worksheet.
I create a worksheet pulling data from other spreadsheets. I go through a
directory and advance rows by using x+1. At the the end I don't know how
many rows I have and I don't want to hard code it. How do I use a variable
in the Range expression.
I only know

Range("A6:AT255")

Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Sort Selection

awesome thanks

"Tom Ogilvy" wrote:

Range("A6:AT" & x)

0r
Range("A6:AT" & x + 1)

also

Range(cells(6,"A"),cells(x,"AT"))

or x + 1 of course.


--
Regards,
Tom Ogilvy

"ibbm" wrote:

I am trying to sort a range in my worksheet.
I create a worksheet pulling data from other spreadsheets. I go through a
directory and advance rows by using x+1. At the the end I don't know how
many rows I have and I don't want to hard code it. How do I use a variable
in the Range expression.
I only know

Range("A6:AT255")

Thanks


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Sort Selection

great idea, thanks.

"Dave Peterson" wrote:

Can you pick out a column that always has data?

Dim LastRow as long

with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row

.range("a6:At" & lastrow).sort...

end with



ibbm wrote:

I am trying to sort a range in my worksheet.
I create a worksheet pulling data from other spreadsheets. I go through a
directory and advance rows by using x+1. At the the end I don't know how
many rows I have and I don't want to hard code it. How do I use a variable
in the Range expression.
I only know

Range("A6:AT255")

Thanks


--

Dave Peterson

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
How can I sort a selection of cells into random order? IanS Excel Discussion (Misc queries) 2 June 14th 07 12:31 PM
Selection.Sort error Krager Excel Programming 3 September 3rd 05 06:12 PM
Macro - Data Sort -Variable Selection Frantic Excel-er Excel Discussion (Misc queries) 3 June 6th 05 10:33 PM
Selection.Sort not working? Avery[_2_] Excel Programming 2 May 5th 04 07:03 PM
Need a macro for selection and sort gmangad[_5_] Excel Programming 1 January 11th 04 11:44 AM


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