Upcoming Power Excel Seminars
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: VBA Help, autofilter by an array populated from a range

  1. #1
    New Member
    Join Date
    Nov 2017
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA Help, autofilter by an array populated from a range

    I'm trying to sort a date column by a range of dates found in a column of another sheet. I feel like my issues is with my weak understanding of populating arrays. Am I declaring and populating the array "Arraystring" correctly? If so why am I not able to autofilter the date column I need to.

    Code:
    Private Sub Click_Generate_Click()Dim Arraystring(30) As String
    
    
    If IsNull(ListBox_Month.Value) Then
        MsgBox ("Please select a month")
    Else
        Mon = ListBox_Month.Value
        
        Select Case Mon
            Case "January"
            
            Case "November"
            For i = 2 To 29
                Sheets("Dates").Activate
                Arraystring(i) = Cells(i, 8).Value
            Next i
                Windows("FY18 SH DAILY ANALYTICALS.xlsx").Activate
                ActiveSheet.ListObjects("Table5").Range.AutoFilter Field:=1, Criteria2:=Arraystring, Operator:=xlFilterValues
                
            
            Case "December"
                FilterMonth = Sheets("Dates").Range("B12").Value
        End Select
    Last edited by 86ms3; Nov 21st, 2017 at 11:35 AM.

  2. #2
    New Member
    Join Date
    Nov 2017
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Help, autofilter by an array populated from a range

    So I checked, I am populating the array correctly but I still can't figure out how to autofilter the data column.
    Last edited by 86ms3; Nov 21st, 2017 at 11:39 AM.

  3. #3
    New Member
    Join Date
    Nov 2017
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Help, autofilter by an array populated from a range

    Nevermind I'm dumb, just used DTPicker and

    Code:
    Private Sub Click_Generate_Click()    Dim date1 As Date
        Dim date2 As Date
        
        date1 = DTPicker_From
        date2 = DTPicker_To
        Windows("FY18 SH DAILY ANALYTICALS.xlsx").Activate
        ActiveSheet.ListObjects("Table5").Range.AutoFilter Field:=1, Criteria1:= _
            ">=" & date1, Operator:=xlAnd, Criteria2:="<=" & date2
        Workbooks("ABC Report Generator.xlsm").Activate
        Unload Me
    End Sub

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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