+ Reply to Thread
Results 1 to 4 of 4

if cell is a certain day macro

  1. #1
    redb
    Guest

    if cell is a certain day macro

    I need help with writing a macro that would run if and only if the date value
    in A1 is a Tuesday. The date written in A1 is in the format dd-mm-yyyy. If
    it is a Tuesday, then the macro would call a seperate private macro named
    TuesdayMacro. Is there any way to do that?

    Thanks!

  2. #2
    JMB
    Guest

    RE: if cell is a certain day macro

    Do you want the macro to run automatically whenever the data in A1 is
    changed? If so, you could right click on your sheet tab, select view code
    and paste the following into the code window.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then _
    If Application.Weekday(Target.Value) = 3 Then
    Call TuesdayMacro
    End Sub


    If you want to decide when you want to run it, you can put this into a
    regular VBA module (and attach it to a button or call it from other code):

    Sub TestDay()
    If Application.Weekday(Worksheets("Sheet1").Range("A1").Value) = 3 Then _
    Call TuesdayMacro
    End Sub

    "redb" wrote:

    > I need help with writing a macro that would run if and only if the date value
    > in A1 is a Tuesday. The date written in A1 is in the format dd-mm-yyyy. If
    > it is a Tuesday, then the macro would call a seperate private macro named
    > TuesdayMacro. Is there any way to do that?
    >
    > Thanks!


  3. #3
    redb
    Guest

    RE: if cell is a certain day macro

    Thank you! The second one is exactly what I needed, but it is nice to know
    the first option as well.

  4. #4
    JMB
    Guest

    RE: if cell is a certain day macro

    Most welcome!

    "redb" wrote:

    > Thank you! The second one is exactly what I needed, but it is nice to know
    > the first option as well.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1