VBA Auto Filter and Copy Paste to a New tab then rename the tab

excelwillmakemerich

New Member
Joined
Nov 12, 2019
Messages
1
Hi to all,

I am a newbie and is learning a lot from this site. I am also hoping that someone can help me with my problem with the VBA code I created via recording a macro.
I have a 9 column master data that I need to filter based on column C "Department" there are times that two departments needs to be group in one sheet together.
I have a 2 row header, row1 and row 2 (see image Sample_MasterData.gif) attached.

I created a tab for each department that I need to group and just record a macro below, but the output seems to duplicate the column D, E & F to column G, H & I (see attached image Capture.gif). Column H & I has a data validation list Col H - RED, YELLOW, GREEN and Col I as - At Risk, On Track.

I really hope someone can help me. Thank you all in advance.

VBA Code:
Sub AutoFilter2()
'
' AutoFilter2 Macro
' AutoFilter2
'

'
    Range("A2").Select
    Sheets("Approved EXC Inventory (2)").Range("A2:I40").AdvancedFilter Action:= _
        xlFilterCopy, CriteriaRange:=Sheets("LIST").Range("C2:C4"), CopyToRange:= _
        Range("A2"), Unique:=False
    ActiveWindow.SmallScroll Down:=-12
    Sheets("Approved EXC Inventory (2)").Select
    ActiveWindow.SmallScroll Down:=-12
    Rows("1:1").Select
    Selection.Copy
 

Attachments

  • Sample_MasterData.gif
    Sample_MasterData.gif
    23 KB · Views: 9
  • Capture.GIF
    Capture.GIF
    27.6 KB · Views: 8

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,213,526
Messages
6,114,122
Members
448,550
Latest member
CAT RG

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