Convert Integer to Date

seasidematt

Board Regular
Joined
Jun 18, 2009
Messages
69
Hi,

Is it possible to convert a integer number into a date format?

I have a problem wheer my dates being input into a vba form that are showing as the integer date.

Is there some code that would validate and convert this number to a date format i.e. DD/MM/YYYY

Any help would be most appreciated

Matt
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Thanks But...<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
My scenario is i have a user form that is completed by our staff this is mirrored by using linked cells from the text boxes.<o:p></o:p>
<o:p></o:p>
When the users complete this form and I copy the data from the mirrored sheet behind into a master database<o:p></o:p>
<o:p></o:p>
I can then pre-populate the form if need at a later time but the date is converting to the integer no. <o:p></o:p>
<o:p></o:p>
I need some sort of VBA validation that would convert this back to a date format<o:p></o:p>

Matt
 
Upvote 0
Thanks,

But to a vba novice how would i incorparte that into my spreadsheet

Thansk for your help so far

Matt
 
Upvote 0
Depending on which way you are going:
Code:
Me.Textbox1.Value = CDate(Range("A1").Value)
or:
Code:
Range("A1").Value = CDate(me.Textbox1.Value)
for example.
 
Upvote 0
Hi thanks for this i think were on teh right track but i have added this into my code and cannot get it to work..


Code:
Private Sub datecomp_Change()
Me.datecomp.Value = CDate(Range("bc2").Value)
End Sub

Above is my code.. Am i doing anything incorrectly?

Cheeers
Matt
 
Upvote 0
It doesn't make sense to change the value from within the change event so i don't really know what you are doing.
I notice that you mentioned linked cells earlier - if you are using the ControlSource property to bind the textbox to the cell, I suggest you don't. Life is much easier if you load the data to and from the cells yourself.
 
Upvote 0
Royra thanks for you help so far... <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
Excuse my ignorance and complete un-understanding of vba 6 months ago i couldn’t tell you what vba stood for but after being thrown in the deep end I’m trying to produce a simple way of capturing data from our senior managers.. The old way was copying and pasting each individual cell into a database and could take up to 40mins per form and with over 400 forms and only myself i had to come up with a better way of getting the data into the main database.<o:p></o:p>
<o:p></o:p>
My only solution (Due to my limited knowledge and curiosity) I came across the control toolbox in excel i noticed that I could link cells from a form that a created on one sheet to another sheet that was hidden from public view.<o:p></o:p>
<o:p></o:p>
Once the user has sent this back to me I would unhide and copy the data in the second data sheet as this mirrored the database.<o:p></o:p>
<o:p></o:p>
Everything is working brilliantly and has saved me loads of time and given me a large pat on the back by my managers. <o:p></o:p>
<o:p></o:p>
Now the problem that i have is that data if i was to copy it back into the sheet to show on the form then the data format has been converted to the integer no i.e. 44095 its shows correctly on the hidden sheet but shows as integer on the form sheet<o:p></o:p>
<o:p></o:p>
So this is my problem and I’m sure there is some VBA that can overcome this.. <o:p></o:p>
<o:p></o:p>
Anyway thanks for your help so far<o:p></o:p>
<o:p></o:p>
Matt<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,215,499
Messages
6,125,163
Members
449,210
Latest member
grifaz

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