VBA Date

AndrewKent

Well-known Member
Joined
Jul 26, 2006
Messages
889
Hi there,

If I have a date 20/09/2011, I want to turn this into a string that simply says "September" using VBA.

How can I do this?

Kind regards,

Andy
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try:

Format(DateValue, "mmmm")
 
Upvote 0
Try like this

Code:
Sub btest()
Dim s As String
s = Format(DateValue("20/09/2011"), "mmmm")
MsgBox s
End Sub
 
Upvote 0
Brilliant guys thank you,

And if I wanted to do this via a formula to get the same result, how would I do it? MONTH will give me the numerical value but again I want "September"

Kind regards,

Andy
 
Upvote 0
If you mean directly on a spreadsheet instead of VBA, then, just use "TEXT" instead of "FORMAT", i.e.
=TEXT(A1, "mmmm")
 
Upvote 0
Another VBA one for you. I want to update this VBA routine further, that if the date falls in "September" I want this to show another variable as "October" as well.
 
Upvote 0
Format(DateAdd("m",1,DateValue), "mmmm")
 
Upvote 0
You could also try this:
Code:
strMonth = MonthName(Month("20/09/2011"))
 
strNextMonth = MonthName(Month("20/09/2011")+1)
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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
Back
Top