date extraction

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
 
G

Gary''s Student

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
 
G

Gord Dibben

Selection.NumberFormat = "m/d/yy;@" simply formats the date to Text

Can you post the entire macro?


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top