Format

chiragggg

Board Regular
Joined
Mar 18, 2010
Messages
197
Hi,

I have a macro which is supposed to create the month (-1) and change format to "mmm" however it seems to change to Jan,

Code below - the formula gives a number.

Range("A2").Select
Selection.NumberFormat = "mmm"
ActiveCell.FormulaR1C1 = "=MONTH(NOW())-1"
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Should it be?

Code:
With Range("A2")
    .NumberFormat = "mmm"
    .Formula = "=DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY()))"
End With
 
Upvote 0
To show where you've gone wrong, your formula is basically "=7-1" which in date format returns 06/01/1900, formatted to month returns Jan.

try

Rich (BB code):
Rich (BB code):
with range("a2")
.numberformat = "mmm"
.formula="=today()-(day(today()+1))
end with
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,323
Members
449,077
Latest member
jmsotelo

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