Formula or code to identify a string as a weekend day

wpryan

Well-known Member
Joined
May 26, 2009
Messages
534
Office Version
  1. 365
Platform
  1. Windows
I've been searching for a solution for a silly thing nagging me... I want to be able to identify a certain day of the week with a string... the string should be today's year, today's month, and a number in a certain cell. I started off just trying to get the date correct, but it's not working. Here's what I've done so far...

Code:
Range("AB14") = Format(Year(Date) & Month(Date) & Range("AB11").Value, "yymmdd")
if I put in range AB11 the number 27, then this should return a date of 15-05-27 (today's date), but instead gives a date of 28-12-93. Where am I going wrong?
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi,

Try it like this


Code:
With Range("AB14")
    .Value = DateSerial(Year(Date), Month(Date), Range("AB11").Value)
    .NumberFormat = "yymmdd"
End With
 
Upvote 0
Thanks, it's working. I was further trying to get the day of the week but got stuck... I added this:
Code:
If Range("AB14").Value = vbWednesday Then
        MsgBox ("Did you really work today?"), vbOKOnly
End If
...the date in AB14 being Wednesday. The code is skipping through, being ignored.
 
Upvote 0
Hi,

Try this


Code:
If Weekday(Range("AB14").Value) = vbWednesday Then
        MsgBox ("Did you really work today?"), vbOKOnly
End If
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

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