Results 1 to 22 of 22

Hide and Autofilter Macro based on Criteria

Threaded View

  1. #1
    Registered User
    Join Date
    03-04-2010
    Location
    Wisconsin
    MS-Off Ver
    Excel 2007, Excel 2010, Excel 2003
    Posts
    87

    Hide and Autofilter Macro based on Criteria

    I am attempting to create a Macro that will look at cell I3 and if it = "GBP" then it will do the following

    Sub HideColumns()
    '
    ' HideColumns Macro
    ' Macro recorded 9/16/2010 by dmau
    '
    
    '
        Range("E:E,G:G,L:L,N:N,P:P").Select
        Range("P1").Activate
        Selection.EntireColumn.Hidden = True
        Selection.AutoFilter Field:=21, Criteria1:="<>0", Operator:=xlAnd
        ActiveWindow.ScrollColumn = 4
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 1
        Selection.AutoFilter Field:=2, Criteria1:="<>0", Operator:=xlAnd
    End Sub
    
    and if I3 = "USD" then
    
    Sub USDHide()
    '
    ' USDHide Macro
    ' Macro recorded 9/16/2010 by dmau
    '
    
    '
        ActiveWindow.SmallScroll ToRight:=3
        Range("F:F,H:H,M:M").Select
        Range("M1").Activate
        ActiveWindow.SmallScroll ToRight:=2
        Range("F:F,H:H,M:M,O:O,Q:Q").Select
        Range("Q1").Activate
        Selection.EntireColumn.Hidden = True
        Selection.AutoFilter Field:=21, Criteria1:="<>0", Operator:=xlAnd
        ActiveWindow.ScrollColumn = 4
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 1
        Selection.AutoFilter Field:=2, Criteria1:="<>0", Operator:=xlAnd
    End Sub
    and if blank it don't do anything

    I will admit I used the "Record Macro" to obtain the code shown above. I am unsure how to insert the criteria so that the autofilter macro knows to look to cell I3 and based on whether it is USD or GBP will perform the appropriate macro.

    I have gone thru what I believed were similar posts and can't seem to get past this part. Macro Newbie here but learning everyday! I'm sure I'm close just not close enough
    Attached Files Attached Files
    Last edited by romperstomper; 09-22-2010 at 06:52 PM. Reason: mark solved
    Dawn - Guru in Training

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