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
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

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")
 

Watch MrExcel Video

Forum statistics

Threads
1,123,057
Messages
5,599,550
Members
414,316
Latest member
ExcelLee

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