ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting data automatically (https://www.excelbanter.com/excel-programming/311011-sorting-data-automatically.html)

scottwilsonx[_34_]

Sorting data automatically
 

Hello All, Hope someone can help...

I have a table in excel, range: c11:h584 where row C11:H11 contains th
titles.
What I would like to do is automatically sort the column by row G.

I may want to change the macro to sort on different columns - is i
possible to build this into the macro using a msgbox (for example)

Is there a way to automate this sort function ?

Many thanks for your help.
Regards

Scott

--
scottwilson
-----------------------------------------------------------------------
scottwilsonx's Profile: http://www.excelforum.com/member.php...fo&userid=1112
View this thread: http://www.excelforum.com/showthread.php?threadid=26272


Tom Ogilvy

Sorting data automatically
 
Turn on the macro recorder and select the range, then do Data=Sort and
select Column G.

Turn off the macro recorder.

Now you c
an replace the Key1:=Range("G11") with a variable such as
dim rng as Range
On error resume next
set rng = Application.Inputbox("Click mouse on a cell in the column to use
for sorting",type:=8)
On error goto 0
if not rng is nothing then
Range("C11:H584").Sort _
Key1:=rng, Order1:=xlascending, _
headers:=xlYes
Else
Msgbox "Nothing selected, bye"
exit sub
End if

--
regards,
Tom Ogilvy

"scottwilsonx" wrote in message
...

Hello All, Hope someone can help...

I have a table in excel, range: c11:h584 where row C11:H11 contains the
titles.
What I would like to do is automatically sort the column by row G.

I may want to change the macro to sort on different columns - is it
possible to build this into the macro using a msgbox (for example)

Is there a way to automate this sort function ?

Many thanks for your help.
Regards

Scott.


--
scottwilsonx
------------------------------------------------------------------------
scottwilsonx's Profile:

http://www.excelforum.com/member.php...o&userid=11128
View this thread: http://www.excelforum.com/showthread...hreadid=262722





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com