DateSerial

mattDrum

New Member
Joined
Jan 27, 2014
Messages
10
Hallo!

I use DateSerial like this "DateSerial(2014, 4, 1)" in vba.
I wonder if I can do this "DateSerial(201*, 4, 1)" the text in vba gets red like something is wrong, but it still works.
Is there another way to do this? I dont want to chance the code every year!

Thanks!

/Matt
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
Office Version
  1. 365
Platform
  1. Windows
Matt

If the code goes red it means there's a syntax error and the code won't compile or run.

So I'm not sure what you mean when you say DateSerial(201*, 4, 1) works.

What are you trying to do anyway?
 

mattDrum

New Member
Joined
Jan 27, 2014
Messages
10
I cant explain the code goes red but it works. I dont know why or how but i does.
I have an excel workbook for every year, if I use "DateSerial(2014, 4, 1)" then i have to change it to "DateSerial(2015, 4, 1)" next year!
I dont want that, that why i wonder if i can do this instead "DateSerial(201*, 4, 1)" or if there is a better way.
/Matt
 

Watch MrExcel Video

Forum statistics

Threads
1,123,110
Messages
5,599,773
Members
414,336
Latest member
Nicolas2465

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
Top