Consulting

Results 1 to 7 of 7

Thread: Macro filtered in column no fill cells in selected sheets

  1. #1
    VBAX Tutor
    Joined
    Sep 2012
    Location
    London
    Posts
    237
    Location

    Macro filtered in column no fill cells in selected sheets

    Hello everybody,
    about a week ago on this site I asked for help to make a macro, but to this day I have no answer, and I am now writing to you about a cooperation.This is what I'm trying to do:
    In column A2 (here I have a filter), down from a3 have text lines are painted in several colors (orange, green, red) and there are not colored (no fill).
    This column is the same in all other 46 sheets (sales, city 1, product 2, product 1, etc.).
    I want to make a macro and a button with which it pushed, only filters no fill cells in my sheets. When pressed a second time to button my column back in its original form.
    Thank you once again.
    Sub fillnofill()
    Sheets("Blag total").Select 'how to add the names of the other sheets?
        Range("A2").Select
        ActiveSheet.Range("A2").AutoFilter Field:=1, Operator:= _
            xlFilterNoFill
    'how to add something that I one button to perform two actions?
        Range("A2").Select
        ActiveSheet.Range("A2").AutoFilter Field:=1
        Range("A2").Select
    End Sub

  2. #2
    VBAX Regular
    Joined
    Feb 2013
    Posts
    52
    Location
    This doesn't answer your question, although it does filter according to interior cell color, sort of....
    it filters for yellow, it filters for green, it won't filter for white. I don't know why, perhaps someone else knows.
    With ActiveSheet
        If .AutoFilterMode = False Then
            'RGB(255, 255, 0) is yellow
            'RGB(146, 208, 80) is green
            'RGB(255, 255, 255) is white
            .Range("A2").AutoFilter Field:=1, Criteria1:=RGB(146, 208, 80), Operator:=xlFilterCellColor
        Else
            .AutoFilterMode = False
        End If
    End With
    From your file, link to on the other forum, here's what I used to get the RGB colors
    Sub GetRGBofCell()
        Dim R As Integer
        Dim G As Integer
        Dim B As Integer
        Dim RGB As Long
    RGB = ActiveCell.Interior.Color
    R = RGB And 255
    G = RGB \ 256 And 255
    B = RGB \ 256 ^ 2 And 255
    MsgBox R & "," & G & "," & B
    End Sub

  3. #3
    VBAX Tutor
    Joined
    Sep 2012
    Location
    London
    Posts
    237
    Location
    Hello NoSparks,
    My macro is made by hand and do what I want. I just do not know how to add specific names of sheets and how one button to filter and return the entire column of the table.
    ..................Operator:= xlFilterNoFill ' this filtered no fill cells
    Thank you very much.

  4. #4
    VBAX Regular
    Joined
    Feb 2013
    Posts
    52
    Location
    Maybe something like this ?
    Sub test_fillnofill()
        Dim i As Integer
        Dim shtArray As Variant
        
    shtArray = Array("Sheet1", "Sheet3", "Sheet6")
    
    For i = LBound(shtArray) To UBound(shtArray)
        With Worksheets(shtArray(i))
            If .AutoFilterMode = False Then
                .Range("A2").AutoFilter Field:=1, Operator:=xlFilterNoFill
            Else
                .AutoFilterMode = False
            End If
        End With
    Next i
    
    End Sub

  5. #5
    VBAX Tutor
    Joined
    Sep 2012
    Location
    London
    Posts
    237
    Location
    So, so that's what I tried to accomplish.
    Please only when I return all my rows to remain filters (now by clicking the button a second time shows all rows but disappear filters).
    If left so I would have to put filters over 46 sheets - which is not much fun.
    Thanks infinite.

  6. #6
    VBAX Regular
    Joined
    Feb 2013
    Posts
    52
    Location
    Sorry, I don't understand.
    Maybe this guess is closer.

    Sub test2_fillnofill()
        Dim i As Integer
        Dim shtArray As Variant
        
    shtArray = Array("Sheet1", "Sheet3", "Sheet6")
    
    For i = LBound(shtArray) To UBound(shtArray)
        With Worksheets(shtArray(i))
            If .AutoFilterMode = False Then
                .Range("A2").AutoFilter Field:=1, Operator:=xlFilterNoFill
            ElseIf (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Then
                On Error Resume Next
                .ShowAllData
                On Error GoTo 0
            Else
                .Range("A2").AutoFilter Field:=1, Operator:=xlFilterNoFill
            End If
        End With
    Next i
    
    End Sub

  7. #7
    VBAX Tutor
    Joined
    Sep 2012
    Location
    London
    Posts
    237
    Location
    Hello NoSparks,
    everything is alright now.
    Correct me understand. Now I have a filter - when all rows are displayed.
    Mark thread as resolved.
    Many thanks
    Be alive and well

Posting Permissions

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