+ Reply to Thread
Results 1 to 2 of 2

Save and restore Date Filters in vba

  1. #1
    Registered User
    Join Date
    07-07-2017
    Location
    dc
    MS-Off Ver
    2013
    Posts
    1

    Save and restore Date Filters in vba

    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.

    Does anyone know a way to do this when dealing with dates? thanks in advance and happy holidays everyone

    mike

    here is an extract of code where save 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

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,150

    Re: Save and restore Date Filters in vba

    1. What is the type of "filterArray" variable ?
    2. Did you check Ms's contextual help ? (there is a nice example, try to adapt it to your needs, below)

    "The following example stores the address and filtering criteria for the current filtering and then applies new filters"
    Please Login or Register  to view this content.
    "The following example uses the values stored in module-level variables in the previous example to restore the original autofiltering to the Crew worksheet"
    Please Login or Register  to view this content.
    Last edited by mjr veverka; 01-08-2018 at 06:23 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to save (and then restore) the selected cell on a different worksheet
    By Ed_Collins in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-16-2015, 03:31 PM
  2. [SOLVED] Restore a previous save?
    By rhenry2424 in forum Excel General
    Replies: 3
    Last Post: 09-28-2013, 03:05 PM
  3. Save My Settings 2003--Does Restore affect PERSONAL.xls
    By microphish in forum Excel General
    Replies: 0
    Last Post: 05-04-2010, 12:11 PM
  4. Using an INI to save and restore check box values
    By SystemsAccountant in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-19-2010, 04:56 PM
  5. On hard drive, how do I restore .XLS prior to last save?
    By wondervic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2005, 04:05 PM
  6. Replies: 1
    Last Post: 05-20-2005, 09:06 AM
  7. VBA 2003 Save|Change|Restore builtin menu OnAction
    By Jeff Higgins in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2005, 10:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1