Dates just the month?

apwdweb

Board Regular
Joined
Aug 23, 2002
Messages
86
Hi,

I have a column of dates that are in this format:

'01/2004

i'd like to capture just the month element into a variable for comparison purposes. does anyone know the VBA code to capture just the month element of this format?

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

This should get you started. It does assume that the month is always 2 characters.

Tony

Sub bbb()
While Not IsEmpty(ActiveCell)

MsgBox Left(ActiveCell, 2)
ActiveCell.Offset(1, 0).Select
Wend
End Sub
 

apwdweb

Board Regular
Joined
Aug 23, 2002
Messages
86
cool i'm not what i've got as far as text or date yet but suppose it is a date format. what would the code be then?

Thanks for your help. I do appreciate your time and efforts.
 

PaddyD

MrExcel MVP
Joined
May 1, 2002
Messages
14,234

ADVERTISEMENT

=text(a1,"MM")
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,038
Messages
5,856,969
Members
431,843
Latest member
Malahhai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top