Alphabetical sort in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
I thought i'd try the hard questions first.

Thanks Tom.

Regards

Richard.
 
I still can't figure out how to create a macro that will sort the same
information in the same way on multiple sheets in the entire workbook.
Possibly because I can't figure out how to select the whole workbook.
 
something like this (UNTESTED):

sub richard()

dim WS as worksheets
dim myLastRow as long
dim myRange as range

for each ws in activeworkbook
mylastrow = ws.cells(10000,1).end(xlup).row
set myrange = ws.range("a1:d" & mylastrow)
myrange.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, Orientation:=xlTopToBottom
next ws
end sub

this sets a range based on columns a - d, using A1 as the sort key.
adjust to suit. hope it gets you started. try recording a macro on
one of the sheets to get the sort options the way you want them, if
these don't work for you (regarding headers & such).
:)
susan
 

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