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

In a worksheet which will be added to weekly, I would like to sort the data
in columns A:AX by column D.
Rather than create a macro which will look at absolute references (ie.
A4:AX5000), can code be used to determine where the last row is and sort only
rows which contain data?
--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default sorting data

Try recording what you want to do with the data you have. Then, determine a
column that will have data in the last row

Dim lRow as long
Dim aWS as Excel.WOrksheet

set aWS = ActiveWorksheet

'Gets last row of data in column 1. Modify as needed

lRow = aWS.Cells(aws.rows.count,1).end(xlup).row

If you can't figure out how to concatenate that data with lRow, come back.

HTH,
Barb Reinhardt

"Jock" wrote:

In a worksheet which will be added to weekly, I would like to sort the data
in columns A:AX by column D.
Rather than create a macro which will look at absolute references (ie.
A4:AX5000), can code be used to determine where the last row is and sort only
rows which contain data?
--
Traa Dy Liooar

Jock

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default sorting data

Assume D is all data then

with range(range("A1"),Range("D1").End(xlDown) )
.Sort range("d1")
end with


"Jock" wrote:

In a worksheet which will be added to weekly, I would like to sort the data
in columns A:AX by column D.
Rather than create a macro which will look at absolute references (ie.
A4:AX5000), can code be used to determine where the last row is and sort only
rows which contain data?
--
Traa Dy Liooar

Jock

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default sorting data

Try the following:-

Private sub sort()
range("A4:AX4",range("A4:AX4").end(xlDown)).sort range("D4"), xlAscending
End sub


"Jock" wrote in message
...
In a worksheet which will be added to weekly, I would like to sort the
data
in columns A:AX by column D.
Rather than create a macro which will look at absolute references (ie.
A4:AX5000), can code be used to determine where the last row is and sort
only
rows which contain data?
--
Traa Dy Liooar

Jock



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default sorting data

Thanks all who replied, sorted thanks.
--
Traa Dy Liooar

Jock


"Jock" wrote:

In a worksheet which will be added to weekly, I would like to sort the data
in columns A:AX by column D.
Rather than create a macro which will look at absolute references (ie.
A4:AX5000), can code be used to determine where the last row is and sort only
rows which contain data?
--
Traa Dy Liooar

Jock

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
Need help sorting data Yookaroo Excel Worksheet Functions 4 June 30th 09 09:33 PM
Need help sorting data Yookaroo Excel Worksheet Functions 0 June 30th 09 12:08 PM
Sorting data to match existing data Jack C Excel Discussion (Misc queries) 4 May 24th 06 09:48 AM
colors of bar charted data don't follow data after sorting Frankgjr Charts and Charting in Excel 2 January 17th 06 12:33 PM
Sorting Data Henrik Excel Discussion (Misc queries) 0 September 29th 05 02:33 PM


All times are GMT +1. The time now is 05:58 PM.

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"