![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 145
|
When reading in a date value from a cell with the format of mm/dd/yy, how do I convert this to the integer value in code. For example: read in 02/25/02 and have my variable show 37312. I know it's not tough, I just can't seem to find any of my old snippets with the Format code.
As always, thank you for your help. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Here's one way:-
MsgBox CLng(Range("A1").Value) Regards, D |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Posts: 145
|
The date is pre-determined in a closed workbook, I don't need the user screwing it up (if you know what I mean!). I know there is a way through code to format, I just can't find it. Needs to be through code!
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
That is code.
Sub GetNumericDate() Dim lngDateVal As Long lngDateVal = CLng(Range("A1")) End Sub Regards, D |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Posts: 145
|
Crap. I'm sorry DK, I totally read that wrong. I thought you had InputBox there, my bad, that format worked great. Thank you.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|