Using VBA to format Date

eoinymc

Board Regular
Joined
Jan 29, 2009
Messages
203
Hi all,

I am using VBA to format a date and it worked fine, but just decided to stop working it seems!

The code I have is this:

DateVal = Format("01-" & Ind.Cells(2, 4).Value, "mmmm")

The value of Ind.Calls(2, 4) will be either Jan/Feb/Mar/etc...

And I want it to be formatted as January..any ideas why this doesn't work or any other way of doing it?

I know I could just use an index/match or vlookup on a table that has Jan-January, etc...

Any help would be welcome.

cheers,

Eoin
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi Eoin,

If you do a MsgBox Format("01-" & Ind.Cells(2, 4).Value, "mmmm"), what do you get?
How about MsgBox ind.Cells(2, 4).Value, what does it show?
 
Upvote 0
Your code works fine for me.

Are you sure Ind.Cells(2,4) is a TEXT string of Jan or Feb etc?
Or is it actually a date value with the cell formatted as mmm ?

If so, try
DateVal = Format(Ind.Cells(2, 4), "mmmm")
 
Upvote 0
Everytime I do it, I get the following error:

Compile Error:

Wrong number of arguments or invalid property assignment.

But, I know it should work!!!! Arrrggghh!

I have literally copied what you sent me...!

And if I put anything in there, I get the same compile error...

There should only be 2 arguments for Format?! Shouldn't there?

Cheers,

Eoin
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,097
Latest member
mlckr

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