Macro filters identical columns into selected worksheets

K0st4din

Well-known Member
Joined
Feb 8, 2012
Messages
501
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hello, everyone,
please help with your help.
I found this macro that filters through a selected column, but I do not know how to add it to many selected worksheets, I have in the past - Array("Ivan todorov", "Petko Georgiev", etc.)
VBA Code:
Sub filter()
Application.ScreenUpdating = False
Columns("A:F").Select
Selection.Sort Key1:=Range("E2"), Order1:=xlDescending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
Application.ScreenUpdating = True
End Sub
I ask for your cooperation.
Thank you in advance
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I (personally) don't really understand what you want to do.
Your code just brings the values in row 2 up to row 1.
And what do you mean by "add it to many selected worksheets"? Is it that you want to run the macro on different worksheets?
In addition, what do you want to do with the strings you've mentioned?
 
Upvote 0
Filter?
Your code is for Sort.

Does the code you posted work?
 
Upvote 0
Hi, the macro is working. Sort(no filter, this is a an accidental mistake) in column E from largest to smallest. The macro works for one worksheet, and for example I have 20 which are 100% identical in structure and I want to insert - Array (with the names of certain worksheets)
 
Upvote 0
I will write the sheet, but for example - Array("ivan petkov", "Todor Iwanov", ect to the end)
 
Upvote 0
One way (untested)

Code:
Sub filter()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, wsArr

    wsArr = Array("ivan petkov", "Todor Iwanov")

    For Each ws In Sheets(wsArr)

    
        ws.Columns("A:F").Sort Key1:=ws.Range("E2"), Order1:=xlDescending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
    
    Next
    
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
One way (untested)

Code:
Sub filter()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, wsArr

    wsArr = Array("ivan petkov", "Todor Iwanov")

    For Each ws In Sheets(wsArr)

   
        ws.Columns("A:F").Sort Key1:=ws.Range("E2"), Order1:=xlDescending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
   
    Next
   
    Application.ScreenUpdating = True
End Sub
Thank you so much.
It is for this help that I have asked you and I am very grateful.
Once again I want to apologize for filtering and sorting.
It is not intentionally written. :)
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top