Macro to tell me if any dates are not a Monday

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I have a list of dates that update everyday,
All i need is a macro that will tell me if any of those dates are not a monday

So the data is in column I,
all i need for now is a macro that checks the dates in column I, ignores blank cells and tells me if any of the dates are not a monday, all cells will only contain either a date or a blank.

Please help if you can

Thanks
Tony
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
assuming your dates are in a standard format perhaps something like this
VBA Code:
set range = range(enter your range here)
for each cel in range
   
  If cel <> "" then
        If Weekday(Cel) <> 2 then
            msgbox "date is a monday"
          else
                msgbox  "date is not a monday"
        end if
    
    else
  end if

next cel
 
Upvote 0
@gordsky

You need to swap your msgbox's or change the <>2 to = 2. ;)
Whoops, thanks for the catch JohnnyL, the correct code should be

set range = range(enter your range here)
for each cel in range

VBA Code:
 If cel <> "" then
        If Weekday(Cel) = 2 then
            msgbox "date is a monday"
          else
                msgbox  "date is not a monday"
        end if
    
    else
  end if

next cel
 
Upvote 0
Solution

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top