month according to numbers

D

douvid

Hi ,

lets say I have set X = 1 and I want this to become x=JAN , y=2 to y=FEB, .... I know I can do this through the textocolumn but my problem is that these are variables in my macro and not cells in the worksheet.

Is there a way I could achieve this ??
Thanks for your help.
 
J

J.E. McGimpsey

One way:

Dim x As Variant
Dim y As Variant
x = 1
y = 2
x = UCase(Application.GetCustomListContents(3)(x))
y = UCase(Application.GetCustomListContents(3)(y))

Another:

Dim x As Variant
Dim y As Variant
x = 1
y = 2
x = UCase(Format(DateSerial(1, x, 1), "MMM"))
y = UCase(Format(DateSerial(1, y, 1), "MMM"))
 
E

Edwin Tam (MS MVP)

See the following simple example
It uses "FORMAT" to convert a date into a format of "mmm", which shows only the month of a date in the format of "Jan", "Feb", etc

Sub example(
Dim
x =
x = Format(DateSerial(2003, x, 1), "mmm"
MsgBox
End Su

Regards
Edwin Ta
[email protected]


----- douvid wrote: ----

Hi ,

lets say I have set X = 1 and I want this to become x=JAN , y=2 to y=FEB, .... I know I can do this through the textocolumn but my problem is that these are variables in my macro and not cells in the worksheet.

Is there a way I could achieve this ??
Thanks for your help.
 
D

Dave Peterson

If you're using xl2002 (or higher):

MsgBox UCase(MonthName(3, abbreviate:=True))
 
Top