Consulting

Results 1 to 5 of 5

Thread: Solved: Criteria1:=strDate

  1. #1

    Solved: Criteria1:=strDate

    Hi all! I have some code that I run on a spread sheet of data (duh), this code allows me to select a specific date. What I would like to be able to do is pick a date and get the date I pick plus the next 5 days. I've tried Criteria1:=strDate +5 but it doesn't work. Any ideas? Here is my current code and thank you for taking the time to look.
    [vba]strDate = InputBox("Please enter start date", "Date Entry")
    strDate = ">=" & strDate
    If strDate = "" Then
    Exit Sub
    End If
    Selection.AutoFilter Field:=3, Criteria1:=strDate, Operator:=xlAnd[/vba]

    This gives me the date I enter plus everything greater than that...
    What happens if you get scared half to death twice?

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Try this
    [VBA]
    Dim strDate As String

    strDate = InputBox("Please enter start date", "Date Entry")
    If Not (IsDate(strDate)) Then
    Exit Sub
    End If
    Selection.AutoFilter Field:=3, Criteria1:=">=" & strDate, Operator:=xlAnd _
    , Criteria2:="<=" & DateValue(strDate) + 5
    [/VBA]

  3. #3
    Quote Originally Posted by JKwan
    Try this
    [vba]
    Dim strDate As String

    strDate = InputBox("Please enter start date", "Date Entry")
    If Not (IsDate(strDate)) Then
    Exit Sub
    End If
    Selection.AutoFilter Field:=3, Criteria1:=">=" & strDate, Operator:=xlAnd _
    , Criteria2:="<=" & DateValue(strDate) + 5
    [/vba]
    Hey, works good! It actually pulls 6 days but that's no biggie...I can mod that. Thank you for your time, I really do appreciate it.
    What happens if you get scared half to death twice?

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Quote Originally Posted by davmec93
    What I would like to be able to do is pick a date and get the date I pick plus the next 5 days.
    The code that JKwan gave you was based on what you asked for.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    Quote Originally Posted by Aussiebear
    The code that JKwan gave you was based on what you asked for.
    You are correct!
    What happens if you get scared half to death twice?

Posting Permissions

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