Hi Guys,
I’m a newby at excel VBA programming and struggling with handling dates.
In my sheet cell B2 has a date which is, for example, 1/1/2018 but it shows as jan/18 because of formatting reasons.
I have 2 variables: MyYear which has the year and MyMonth which has the month (first 3 characters of the month name). Btw these variables are not necessary the current date!
I’m struggling how to validate that combination of variables MyMonth/MyYear to the content of cell B2.
Further actions in VBA are depending if the right date combination exists in cell B2 or not.
I’ve tried the below code but that doesn’t work.
Any help or suggestions would be appreciated.
I’m a newby at excel VBA programming and struggling with handling dates.
In my sheet cell B2 has a date which is, for example, 1/1/2018 but it shows as jan/18 because of formatting reasons.
I have 2 variables: MyYear which has the year and MyMonth which has the month (first 3 characters of the month name). Btw these variables are not necessary the current date!
I’m struggling how to validate that combination of variables MyMonth/MyYear to the content of cell B2.
Further actions in VBA are depending if the right date combination exists in cell B2 or not.
I’ve tried the below code but that doesn’t work.
Rich (BB code):
Rich (BB code):
If Range("B2").Value = (MyMonth & "/" & MyYear) then
Any help or suggestions would be appreciated.