Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need help sorting data | Excel Worksheet Functions | |||
Need help sorting data | Excel Worksheet Functions | |||
Sorting data to match existing data | Excel Discussion (Misc queries) | |||
colors of bar charted data don't follow data after sorting | Charts and Charting in Excel | |||
Sorting Data | Excel Discussion (Misc queries) |