Converting date in VBA Excel [Solved/Closed]

Report
-
 Roger -
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!

3 replies

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.
Posts
2657
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 22, 2020
440
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!