Loop through filter criteria and copy paste values from other files

GerardoLopez22

New Member
Joined
Jul 23, 2018
Messages
2
I have a database to be updated every month. I need to filter the table by each criteria in cell C8 and then open another file copy the values from column O and paste them in the database and go to the next filter criteria open the next file and repeat all in the same column. Then for the next execution (next month) this to be done, but the values to be pasted in the next column.

I recorded a macro doing two months for the same filter criteria and obtained this. I do not know how to make the loop for the criteria and then loop for the next column.

There 18 criteria to filter for the 12 months of the year

Code:
Sub BringVal()
    Range("O9:O290").Select
    Selection.Copy
    Windows("TEST FILE-OEE-OptimiyedCode.xlsm").Activate
    ActiveWindow.SmallScroll Down:=-24
    Range("O9").Select
    ActiveSheet.Paste
    Range("O22").Select
    ActiveWindow.SmallScroll Down:=-36
    Windows("NOM CBG Common Approach OEE Mistakes per 100 m 01-2018.xlsx").Activate
    ActiveWindow.Close
    Sheets("Database").Select
    Range("P9:P290").Select
    Selection.Copy
    Windows("TEST FILE-OEE-OptimiyedCode.xlsm").Activate
    Range("P9").Select
    ActiveSheet.Paste
    Range("O22").Select
    ActiveSheet.Range("$C$8:$AB$3000").AutoFilter Field:=13, Criteria1:=RGB(255 _
        , 255, 153), Operator:=xlFilterCellColor
    Range("O22:O2996").Select
    ActiveWindow.SmallScroll Down:=9
    Application.CutCopyMode = False
    ActiveWindow.SmallScroll Down:=-15
    Range("P66").Select
    ActiveSheet.Range("$C$8:$AB$3000").AutoFilter Field:=13
    ActiveWindow.SmallScroll Down:=-18
    Range("P22").Select
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I'm confused as to what the criteria are and what the code does for you. The code contains a lot of you scrolling through the sheets and opening different workbooks
 
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,699
Members
449,180
Latest member
craigus51286

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