Converting Dates

  • Thread starter Thread starter wutzke
  • Start date Start date
W

wutzke

Given a cell value of "Feb '08 " that is text, how could I
programically convert the value to 02/01/2008 in Date values
 
Sub qwerty()
s = "Feb '08 "
s = Application.WorksheetFunction.Substitute(s, "'", "20")
MsgBox (DateValue(s))
End Sub
 
Given a cell value of "Feb '08 " that is text, how could I
programically convert the value to 02/01/2008 in Date values

Hello wutzke,

Here is one way. The single quote is represented by Chr$(39) for
readability.

Dim D

D = Split("Feb '08", Chr$(39))
D = CDate(D(0) & "1, " & D(1)) 'D is now = 2/01/2008

Sincerely,
Leith Ross
 
Or, staying totally within VBA, using this for your second line instead...

s = Replace(s, "'", "20")

Rick
 

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

Similar Threads


Back
Top