date extraction

  • Thread starter Thread starter Donna
  • Start date Start date
D

Donna

I have a macro set up that pulls out the dates from my information.

I am not sure but I think what I have below is the spot that defines the
date format to pull out my dates from my data. If I put 2/2/10 it does not
pull out the date. If I put 02 it does pull out the date. Is there a way so
it will pull it out whether I put 2 or 02 for the month?

Selection.NumberFormat = "m/d/yy;@"
Thank You
 
Get it as a String and then convert to a Date:

Sub luxation()
Dim s As String, d As Date
s = Selection.Text
d = DateValue(s)
MsgBox d
End Sub
 
Selection.NumberFormat = "m/d/yy;@" simply formats the date to Text

Can you post the entire macro?


Gord Dibben MS Excel MVP
 
Back
Top