Consulting

Results 1 to 4 of 4

Thread: VBA Date Filtering Issue

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA Date Filtering Issue

    I am using the below vba code to filter a spreadsheet on open to show the current month and all future dates and I can't for the life of me get it to show null values... where the date isn't populated. Any help would be appreciated!

    Private Sub Workbook_Open()
    Sheets("Sheet1").Select
    'startdate as date
    Dim startDate As Date
    'startdate as long for excel
    Dim lstartDate As Long
    'get start date, day = always 1
    startDate = DateSerial(Year(Now), Month(Now), 1)
    lstartDate = startDate
    'filter everything before current month
    'you see this month + future
    ActiveSheet.Range("A1").AutoFilter Field:=6, Criteria1:=">=" & lstartDate
    End Sub
    Last edited by Aussiebear; 03-25-2024 at 02:36 PM. Reason: Added code tags to supplied code

Tags for this Thread

Posting Permissions

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