VBA Help, autofilter by an array populated from a range

86ms3

New Member
Joined
Nov 16, 2017
Messages
14
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:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
So I checked, I am populating the array correctly but I still can't figure out how to autofilter the data column.
 
Last edited:
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top