Sort Multiple Sheets with Macro Loop

  • Hello All,


    I am trying to sort every worksheet that I have in a workbook with a few hundred sheets. Basically I want to filter every sheet descending based on the value in column B5 down. If I only had to do it once the process would be, apply filter across row 3 sort column B descending and then take off the filter.


    An example of the before would be Sheet1 and the after would be Sheet1 Result, Sheet2 and Sheet2 Result.


    I have attached an example file in the hopes that you can help.


    Thank you!

  • Re: Sort Multiple Sheets with Macro Loop


    Here is the code.let me know if it helps!


    Code
    1. Sub M()
    2. For Each ws In ActiveWorkbook.Worksheets
    3. ws.Activate
    4. ws.Range("B4", Range("B" & Rows.Count).End(xlUp).Address).Sort Key1:=[b4], _
    5. Order1:=xlDescending, Header:=xlYes
    6. Next ws
    7. End Sub