Autofilter data for multiple criteria and write name to all visible cells till last row

aman2059

Board Regular
Joined
Jan 17, 2016
Messages
75
Could you anyone please help me on below.

I need my code to do following

1. filter for one criteria("=SE02") in column Q
2. Go to column R, write "AMC India" on all visible cells till last row
3. remove filter given in point 1.
4. Again filter for multiple criteria( ">= YC101", "<= MR107", "WE109") in column AL
5. Go to column R, write "YMC India" on all visible cells till last row

Below is my code. Thank you in advance for your help :)

Code:
Sub Save214012016()
    
    Dim lastRow As Long

    Range("Q1").Select
    Selection.AutoFilter
    ActiveSheet.Range("A1:A, lastrow").AutoFilter Field:=17, Criteria1:= _
        "=*SE02*", Operator:=xlAnd
    Range("R1").Select
    ActiveCell.Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "AMC India"
    ActiveCell.Copy
    Range("R2:R, lastrow").SpecialCells(xlCellTypeVisible).PasteSpecial xlValues

     Selection.AutoFilter
         Range("AL1").Select
    ActiveSheet.Range("$A$1:$BA$5985").AutoFilter Field:=37, Criteria1:=Array( _
    ">= YC101", "<= MR107", "WE109"), Operator:=xlFilterValues

     Range("R1").Select
    ActiveCell.Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "YMC India"
    ActiveCell.Copy
    Range("R2:R, lastrow").SpecialCells(xlCellTypeVisible).PasteSpecial xlValues

End sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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