Sorting data automatically

  • Thread starter Thread starter scottwilsonx
  • Start date Start date
S

scottwilsonx

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top