Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
'IF' Macro to insert cell contents to alternate cell if cell not e | Excel Worksheet Functions | |||
using a cell value to control a counter inside a macro and displaying macro value | Excel Worksheet Functions | |||
macro to run a separate macro dependent on value in cell | Excel Programming | |||
Please help! Macro to change cell contents based on cell to the left | Excel Programming | |||
Question: Cell formula or macro to write result of one cell to another cell | Excel Programming |