Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
bman342
 
Posts: n/a
Default Sorts on variable ranges

I have data being imported to a spreadsheet that needs to be sorted.
The range of data elements is inconsistent.
I want to automate the sort function.
I recorded a macro that highlights the first data element, which will always
be consistent (say at: A4), and then moves down to a cell that defines a
range that I know will always be larger than the amount of data elements
being imported (say A300). But if I do an alphabetical sort, the blank cells
will be placed first.

If there a way to automatically highlight just the range of data elements,
and then do the sort?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JonR
 
Posts: n/a
Default Sorts on variable ranges

This will work with varying data table lengths as long as there are no blank
cells in between data elements (i.e. you can't have data down to A255 if
there is a blank in A75 -- it will go to A74 and stop)


Sub sort()

Dim inRow

Cells(4, 1).Select

inRow = Selection.End(xlDown).Row

Range(Cells(4, 1), Cells(inRow, 1)).SortSpecial

End Sub

HTH
JonR

"bman342" wrote:

I have data being imported to a spreadsheet that needs to be sorted.
The range of data elements is inconsistent.
I want to automate the sort function.
I recorded a macro that highlights the first data element, which will always
be consistent (say at: A4), and then moves down to a cell that defines a
range that I know will always be larger than the amount of data elements
being imported (say A300). But if I do an alphabetical sort, the blank cells
will be placed first.

If there a way to automatically highlight just the range of data elements,
and then do the sort?

Thanks.

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
Aling multiple sets of data by header column MarkusO Excel Discussion (Misc queries) 2 April 12th 06 08:29 PM
Copy variable ranges fron difernte shets optimus_1973 Excel Worksheet Functions 2 January 8th 06 05:39 AM
Variable ranges John Contact Excel Worksheet Functions 1 June 17th 05 09:02 AM
Sum Variable Ranges Erika Excel Worksheet Functions 6 December 23rd 04 04:52 PM
Variable Print Ranges Zshepherd Excel Discussion (Misc queries) 0 December 2nd 04 04:23 PM


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