vba-在sheet中點擊指定的cell 跳轉到另一個sheet中過濾出兩個條件的內容



Private Sub Worksheet_BeforeDoubleClick_bak(ByVal Target As Range, Cancel As Boolean)orm

'在sheet中點擊cell時激活該方法get

    Dim platform As Stringit

    If Target.Row = 4 Thenio

        platform = "eDream"form

    ElseIf Target.Row = 6 Thenselect

        platform = "ODM"方法

    End Ifim

    '狀態沒有細分的方法filter

    ' Call selectState(platform, 2, Target.Column)co

    '狀態有細分的方法

    Select Case Target.Column

        Case 11, 12

            Call selectState(platform, 3, Target.Column)

        Case Else

            Call selectState(platform, 2, Target.Column)

    End Select

    'MsgBox Target.Columns, Target.Rows

End Sub

Function selectState_bak(platform As String, stateRowNum As Integer, stateColumnNum As Integer)

    '選擇平臺的狀態

    Dim state As String

    '獲取狀態

    state = Cells(stateRowNum, stateColumnNum).Value

    '篩選指定平臺,指定狀態的方法

    Call filterPlatformByState(platform, state)

End Function

Function filterPlatformByState_bak(platform As String, state As String)

    '篩選指定平臺,指定狀態的方法

    Dim totalcount As Integer

    '激活篩選sheet,【"Row data"】是被激活sheet名稱

    Sheets("Row data").Select

    '取得被激活sheet的總行數

    totalcount = Sheets("Row data").[a1].CurrentRegion.Rows.Count

    '篩選平臺,【4】是平臺關鍵字所在的列

    ActiveSheet.Range("$A$1:$X$" & totalcount).AutoFilter Field:=4, Criteria1:=platform

    '篩選狀態,【12】是平臺狀態關鍵字所在的列

    ActiveSheet.Range("$A$1:$X$" & totalcount).AutoFilter Field:=12, Criteria1:=state

End Function

相關文章
相關標籤/搜索