• If/Then based on day of week

    Author
    Topic
    #463716

    Hello all,

    Is there a way to have a macro run a certain set of commands based on the day of the week?

    For example, If the day of the week is Monday, I want it to run something different than it would on a Tuesday.

    Thanks!

    Viewing 0 reply threads
    Author
    Replies
    • #1184824

      You can test Weekday(Date):

      Code:
      Sub Test()
        Select Case Weekday(Date)
      	Case vbSunday
        	' Code for Sunday
      	Case vbMonday
        	' Code for Monday
      	Case vbTuesday
        	' Code for Tuesday
      	Case vbWednesday
        	' Code for Wednesday
      	Case vbThursday
        	' Code for Thursday
      	Case vbFriday
        	' Code for Friday
      	Case vbSaturday
        	' Code for Saturday
        End Select
      End Sub
      • #1184835

        You can test Weekday(Date):

        Code:
        Sub Test()
          Select Case Weekday(Date)
        	Case vbSunday
          	' Code for Sunday
        	Case vbMonday
          	' Code for Monday
        	Case vbTuesday
          	' Code for Tuesday
        	Case vbWednesday
          	' Code for Wednesday
        	Case vbThursday
          	' Code for Thursday
        	Case vbFriday
          	' Code for Friday
        	Case vbSaturday
          	' Code for Saturday
          End Select
        End Sub

        That worked great. Thanks!

    Viewing 0 reply threads
    Reply To: If/Then based on day of week

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: