+ Reply to Thread
Results 1 to 5 of 5

Excel 2003 Autofilter error?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127

    Excel 2003 Autofilter error?

    Hi all

    I have written a macro for which the code is shown below.
    Using excel 2007 but stored as .xls because an assistant user is gonig to use the workbook with excel2003.

    The assistant user is experiencing an error titled "Object doesn't support this property or method". I only have a screenshot of this error message. Unfortunately, the assistant sits in a different geographical location so I'm unable to observe the error or replicate it on my side.

    Compatibility checker in my excel shows taht there are NO ISSUES.
    The macro runs perfectly on my computer.

    Macro does the following (1) opens a .csv file, (2) copies all the content from the sheet, (3) switches back to my workbook, (4) inserts a new sheet, (5) pastes the data, (6) selects range (7) runs autofilter on 2 criteria (8) copies the filtered results (9) adds new sheet and pastes the copied data from (8).

    From the screenshot that was supplied to me, I can see that the code is executing up to this line, and then the error msg is displayed:

    'LastRow definition for imported bank statement
    LastRow = Sheets("Import").Cells(Rows.Count, "A").End(xlUp).Row


    This is where the error msgbox pops up.
    The screenshot shows all cells highlighted. If I run the code up to cursor at the end of this line, then on my screen the Excel spreadsheet looks the same as the screenshot.

    The next line of code goes on to the Autofilter.
    Columns("A:I").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$I$" & LastRow).AutoFilter Field:=3, Criteria1:="="
    ActiveSheet.Range("$A$1:$I$" & LastRow).AutoFilter Field:=2, Criteria1:="<>"


    The screenshot does not show Columns A-I being selected.
    So I'm guessing that this Autofilter type is not supported in Excel 2003? But I can't seem to find any more info on internet search.

    Have checked Microsoft website here as advised by MarvinP.
    Also used Bing search but with no success.

    Here is the entire code -
    Dim LastRow As Long
        
        'used to open file from dialog box
        Dim FilesToOpen As Variant
        
        On Error GoTo ErrHandler
        
        'dialog box to check with user if file stored in HDD
        Answer = MsgBox("Have you stored bank statement file as .csv on your computer ?", vbYesNo, "IMPORTING STANDARD BANK - BANK STATEMENT FILE")
        If Answer = vbNo Then
            MsgBox ("First store bank statement as .csv on your computer")
            End If
            
        'dialog box to select file to incorporate
        FilesToOpen = Application.GetOpenFilename _
          (filefilter:="CSV_Bankstatement* Files (*.CSV), *.csv", FilterIndex:=1, _
          MultiSelect:=False, Title:="File to Import")
        
        If TypeName(FilesToOpen) = "Boolean" Then
            MsgBox "No Files were selected"
            GoTo ExitHandler
        End If
            
         'Open file and Copy sheets from selected workbook
            Workbooks.Open Filename:=FilesToOpen
    
        'Code re-written at this point to accommodate excel-2003 users
        'Copy contents from .csv file into new sheet on workbook
            Cells.Select
            Selection.Copy
            ThisWorkbook.Activate
            Sheets.Add
            Range("A1").Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False
        
        'Rename sheet and colour tab
        ActiveSheet.Name = "Import"
        With ActiveWorkbook.Sheets("Import").Tab
            .Color = 5287936
            .TintAndShade = 0
        End With
            
        'Dim LastRow definition for imported bank statement
        LastRow = Sheets("Import").Cells(Rows.Count, "A").End(xlUp).Row
        
        'apply filters
        Columns("A:I").Select
        Selection.AutoFilter
        ActiveSheet.Range("$A$1:$I$" & LastRow).AutoFilter Field:=3, Criteria1:="="
        ActiveSheet.Range("$A$1:$I$" & LastRow).AutoFilter Field:=2, Criteria1:="<>"    
    
        Range("A1:I" & LastRow).Select
        Selection.SpecialCells(xlCellTypeVisible).Select
        Selection.Copy
        
        'Paste to new sheet
        Sheets.Add
        ActiveSheet.Name = "Norefs"
        Range("A5").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        With ActiveWorkbook.Sheets("Norefs").Tab
            .Color = 5287936
            .TintAndShade = 0
        End With
        
        Range("A1").Select
        ActiveCell.FormulaR1C1 = "TRAVELSHOP RECONCILIATION"
        ActiveCell.Offset(1, 0).Range("A1").Select
        ActiveCell.FormulaR1C1 = _
            "Items on bank statement with no invoice or order numbers"
        ActiveCell.Offset(-1, 0).Range("A1").Select
        Selection.Font.Bold = True
        With Selection.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontMinor
        End With
        ActiveCell.Offset(1, 0).Range("A1").Select
        Selection.Font.Bold = True
        
        'turn off autofilters
        Worksheets("Import").Select
        Selection.AutoFilter
        Range("A1").Select
        Worksheets("Norefs").Select
            
        'close source file
        Application.GetSaveAsFilename
        
        MsgBox ("Reports now created. Remember to close source file")
        
    'exit handler
    ExitHandler:
        Exit Sub
            
    'error handler
    ErrHandler:
        MsgBox Err.Description
        Resume ExitHandler
        
    End Sub
    Any suggestions?
    Last edited by rasonline; 03-11-2011 at 01:02 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Excel 2003 Autofilter error?

    What happens if you add a workbook reference to that line?

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Excel 2003 Autofilter error?

    Hi rasonline

    I believe I've encountered this issue in the past. Try creating the new sheet BEFORE the code to copy Filtered Data. Then do your copy paste.

    Something like this (NOT tested)
     Sheets.Add
        ActiveSheet.Name = "Norefs"
    'Do your filtering here then the Copy/Paste
    Sheets("Import").SpecialCells(xlCellTypeVisible).Copy Destination=Sheets("Norefs").Range("A5")
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Excel 2003 Autofilter error?

    Am checking on this today, and will update this post hopefully by tomorrow.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Excel 2003 Autofilter error?

    hi, rasonline, may be I'm wrong but the root of the problem is not the marked line.

    As far as I can see the problem is here:

     'Rename sheet and colour tab
        ActiveSheet.Name = "Import"
        With ActiveWorkbook.Sheets("Import").Tab
            .Color = 5287936
            .TintAndShade = 0
        End With
    If you refer to Excel 2003 VB help file (you saved it as .xls definining Excel 2003 VB for this code) the Tab Object has the following properties:

    - Application property
    - Color Property
    - ColorIndex Property
    - Creator Property
    - Parent Property


    So .TintAndShade property is not used in Excel 2003. Solution: try to comment it out and run the code, I suppose it will run without any troubles.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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