![]() |
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! |
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! |
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. |
All times are GMT +1. The time now is 05:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com