Copy Data

  • Thread starter Thread starter PEdro
  • Start date Start date
P

PEdro

Hi

I have in cell A1 the value 31/09/2003
This is formatted has mmmm/yyyy
So the result is "September 2003"

What code should I write in order for getting the variable
strMon with the
first 3 caracters of September "Sep"

Thanks
Pedro
 
PEdro,

First of all, there isn't a September 31st (at least on my calendar).
When you enter a date in a cell, it's stored numerically.
When you format it, all you're doing is telling Excel how you'd
like it displayed. It doesn't really change its numeric equivalent.
So if there's a date in A1 and you just want the three letter month,
the following should work:

Sub TestMe()
Dim rDate As String
rDate = Format(Range("A1").Value, "mmm")
MsgBox rDate
End Sub

John
 
Back
Top