If Statement or Macro Separate Date 1/12/2010

999HelpPlease

New Member
Joined
Jul 16, 2014
Messages
35
I want to write an if statement or VBA to separate the day, month and year. Instead of reading 1/12/2010 I want the 1 to appear in one column the 12 to appear in another column and the 2010 to appear in a separate column. One of my concerns is the first number can sometimes be two digits and the second number can sometimes be 1 digit. Any suggestions?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
if your date is stored in MyDate

Code:
dim MyDate as Date
MyDate = #1/12/2014#
Range("A1").value = day(mydate)
Range("B1").value = month(mydate)
Range("C1").value = Year(myDate)
 
Upvote 0
I want to write an if statement or VBA to separate the day, month and year. Instead of reading 1/12/2010 I want the 1 to appear in one column the 12 to appear in another column and the 2010 to appear in a separate column. One of my concerns is the first number can sometimes be two digits and the second number can sometimes be 1 digit. Any suggestions?

Are the Dates stored as text or serial numbers?
quick check for serial numbers: Add 1 to date and see if you get the #VALUE Error.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,790
Members
449,468
Latest member
AGreen17

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