![]() |
![]() |
|
|||||||
| 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 |
|
New Member
Join Date: Apr 2002
Location: Michigan, USA
Posts: 17
|
Hi,
I am going to convert the date from text format to numeric number format. Like this: 08/22/1998 = 36029. Could you teach me how to get it using VBA? Thank you very much. ssunchen |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Reasonably simple since VBA will take care of this conversion for you, here's an example:
oDate is the literal date, iDate is the date set as a long integer value. HTH |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
This worked for me, after selecting the range you want to change. Sub test() Dim Rng As Range For Each Rng In Selection If IsNumeric(Rng) Then Rng.NumberFormat = "General" Else On Error Resume Next Rng = DateValue(Rng) On Error GoTo 0 Rng.NumberFormat = "General" End If Next Rng End Sub Bye, Jay |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|