![]() |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 06:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com