Converting date in VBA Excel

Roger - Dec 27, 2010 at 01:48 PM
 Roger - Dec 28, 2010 at 01:54 PM

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!

3 responses

I dont know how to do that in VB code but you can use such a formula
and change the format of the cell to date
I hope it helps.
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Dec 28, 2010 at 09:32 AM
Hi Roger,

Looking for something like this:

ActiveCell.Formula = "=DATE(A2,B2,C2)"
Best regards,
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!