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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,214,651
Messages
6,120,738
Members
448,988
Latest member
BB_Unlv

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