Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jac Jac is offline
external usenet poster
 
Posts: 58
Default How to generalize sorting range in macro???

Hi Tom,

Thanks for your help..............
It's working now! ; )



"Tom Ogilvy" wrote:

If you like Excel to identify the range, then just use a single variable in
the range - preferrable the index range

With Range("D1")
.Sort Key1:=.Cells(1,1), Order1:=xlAscending
End With

or
Dim rng as Range
set rng = Range("A1").CurrentRegion

rng.Sort Key1:=rng(1).Offset(0,3), Order1:=xlAscending


--
Regards,
Tom Ogilvy


"Jac" wrote:

Hi,

I have recorded a macro which would help me to sort a list of data. First,
when I have done with the recording, I found out that the range of the data
list is being hard coded in the marco, for example, Range("A1:F30").Sort
......

But what happen is I may have different ranges of lists! Sometimes, the list
may be shorten then the previous one but sometimes may be longer then. So, I
tried to replace the fixed range with a Range Object variable; but it doesn't
work and the system generated a debug!!!

How actually to solve this problem????
Please advise........

Thanking in advance!!


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
sorting range peyman Excel Discussion (Misc queries) 5 October 27th 07 10:29 PM
Sorting by range planetdust New Users to Excel 3 October 21st 07 01:03 AM
Sorting a Range cmm Excel Discussion (Misc queries) 1 June 30th 06 01:35 PM
sorting a range hawk[_2_] Excel Programming 1 January 1st 06 04:54 PM
Sorting multiple range using a macro onlinepredator Excel Programming 4 August 14th 04 12:52 PM


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