VBA: Advanced Filter header question

gd6noob

Board Regular
Joined
Oct 20, 2017
Messages
170
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,

I have a spreadsheet that retrieves data from various files and I input a column header via array.

VBA Code:
        ary = Array("Row Labels", "Bereavement", "Medical Waiver", "Provincial Leave")
        sht.Range("A1:D1").Value = ary

This is not the problem. The error happens when I used the Advanced Filter copyto method. I have a couple other spreadsheets where I copy from and it contains more headers but I only require the ones listed above.

Spreadsheet 1
YYZ4_Provincial_Tracker_AM.xlsb
ABCD
1Min of BalanceColumn Labels
2Row LabelsBereavementMedical WaiverProvincial Leave
3test 1Not UsedNot Used7
4test 2Not UsedNot Used9
Balances


Spreadsheet 2
YYZ4_Provincial_Tracker_NZ.xlsb
ABC
1Min of BalanceColumn Labels
2Row LabelsBereavementProvincial Leave
3test 3Not Used9
4test 4Not Used8
Balances


Spreadsheet 1 and 2 you can see are pivot tables. There is another tab which gets filled with people's requests and the pivot tables will update. These spreadsheets are used to tracker our workers "Time Off" approved requests and it contains 10 different types but I only need the 3 listed above in my array. As you can see on "Tracker_AM" the header contains all 3 of the time off options while "Tracker_NZ" does not, which means people with names start with N through Z did not request any Medical Waiver time off.

Where my problem is that since I hard coded the header with my array, it throws an error and stops. Is there any way to do this even the header from my source range does not contain all the header from my criteria range?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,213,532
Messages
6,114,176
Members
448,554
Latest member
Gleisner2

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