Converting date in VBA Excel

Solved/Closed
Roger - 27 Dec 2010 à 13:48
 Roger - 28 Dec 2010 à 13:54
Hello,

I have a spreadsheet that has:

Column A: Year
Column B: Month
Column C: Day

Is there a way to convert these 3 columns into the actual date in VB code? I have a form that I need a text box to populate the date from these three columns in the spreadsheet. The reason I simply did not use the date format in the spreadsheet is because the user will be filtering many dates and I was afraid the advance filter would be a little more complicated for them. Thanks if anyone can help!

Related:

3 responses

I dont know how to do that in VB code but you can use such a formula
=B1&"/"&C2&"/"&A2
and change the format of the cell to date
I hope it helps.
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
28 Dec 2010 à 09:32
Hi Roger,

Looking for something like this:

ActiveCell.Formula = "=DATE(A2,B2,C2)"
Best regards,
Trowa
Thanks Trowa worked like a charm at first but now I am getting the error: #VALUE!. I have formatted the cells over and over I just don't know what the heck is going on! Can't I just format the cells to General? The cell that has the formula for the date I have set to the Date format.
Problem solved thanks so much!