sorting in multiple sheets

  • Thread starter Thread starter Ren
  • Start date Start date
R

Ren

Hi Tom,

i have multiple sheets from A to Z
and i need to sort column L
i used this code

Sub sort()
cells.sort Key1:=range("L2"), Header:=xlYes
End Sub

it's working for the single sheet.
but i want it for all the sheets
how to modify your code.i tried but could't get thru.

thanks in advance
Ren
 
If it is all sheets in workbook then use this.....

Sub sort()
Dim wS as Worksheet
For Each wS in Worksheets
wS.cells.sort Key1:=wS.Range("L2"), Header:=xlYes
Next
End Sub

--

Regards,
Nigel
(e-mail address removed)



Ren said:
Hi Tom,

i have multiple sheets from A to Z
and i need to sort column L
i used this code

Sub sort()
cells.sort Key1:=range("L2"), Header:=xlYes
End Sub

it's working for the single sheet.
but i want it for all the sheets
how to modify your code.i tried but could't get thru.

thanks in advance
Ren
 
Hey thanks,

i was adding the workbook before the worksheet.so i was getting errors.
anyway it's working perfectly fine
thanks

Ren

Nigel said:
If it is all sheets in workbook then use this.....

Sub sort()
Dim wS as Worksheet
For Each wS in Worksheets
wS.cells.sort Key1:=wS.Range("L2"), Header:=xlYes
Next
End Sub

--

Regards,
Nigel
(e-mail address removed)
 

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