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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Should it be?

Code:
With Range("A2")
    .NumberFormat = "mmm"
    .Formula = "=DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY()))"
End With
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
14,761
Office Version
  1. 365
Platform
  1. Windows
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
 
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,163,732
Messages
5,833,380
Members
430,206
Latest member
Sami Gaid

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