Save and restore Date Filters in vba

hiici

New Member
Joined
Jul 14, 2017
Messages
14
Hi all,

I am trying to save filters so I can restore later and the logic that sets my criteria1 value fails with "1004 application or object defined runtime error" when the filtered column is a date.

Has anyone figured a way to do this when dealing with dates? I also have a problem restoring color filter objects but I have seen threads that this is not possible so I have decided to issue a message for colors and since I do not get runtime errors, I can live with the colors issue unless someone has an answer to that one also :)

thanks in advance and happy holidays everyone :)

mike

extract of code where filter fails:

Select Case .Operator
Case 1, 2 'xlAnd, xlOr
filterArray(f, 1) = .Criteria1
filterArray(f, 2) = .Operator
filterArray(f, 3) = .Criteria2
Case 0, 3 To 7
filterArray(f, 1) = .Criteria1 <- runtime error here with date filter
filterArray(f, 2) = .Operator
Case Else
filterArray(f, 2) = .Operator
colorcolcount = colorcolcount + 1
strArray = Split(Cells(1, f).Address, "$")
colorcol = strArray(1)
End Select
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,835
Messages
6,181,245
Members
453,026
Latest member
cknader

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