VBA to increase Month shown in a cell by 1 Month

Phil Payne

Board Regular
Joined
May 17, 2013
Messages
131
Office Version
  1. 365
Platform
  1. Windows
Hello all,

A simple vba that works
VBA Code:
Sub Add_One()
Range ("C10").value = Range ("C10").value+1
End sub

So from 999 to 1000 etc...OK but i need to increase by Month i.e. January 2024 moves to February 2024 etc. and number of days in a month vary.

How can I modify the code to change by calendar month over the years (at least to 2030)
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
i.e. January 2024 moves to February 2024
What exactly is in the cell?
  • January 2024 as a Text value?
  • 20 January 2024 as a Date but formatted to just show the month and year?
  • Something else?
 
Upvote 0
Date as a numbe, referenced by a linked cell that is formatted to mmmm yyyy
 
Upvote 0
Date as a numbe, referenced by a linked cell that is formatted to mmmm yyyy
Can it be any date? That is, could it be 31 January or 7 March etc or is it always the first day of the month?

.. and so it currently contains a formula and you want vba to replace that formula result with a new non-formula date in the following month?
If the date is currently 7 March 2023 do you want the new date to be 7 April 2023 or just any date in April since only month and year will be visible?
Give us as much detail as you can please.
 
Upvote 0
Hi Peter,

It can be any date as long as it presents the month and year only e.g. January 2024, February 2024 and so on.

At the moment I have code that modifies a column range of a formula to go to the range to the right.
The ranges are columns recording data on a calendar month basis and the cell on row 2 holds the Month in the format 01/01/2024 that is formatted to show 01 January 2024. Row 1 above is linked (=row2) and formatted to show January 2024 etc.

The ranges are on a sheet called "GPR_Data" and the result needs to show one cell of a sheet named "Actives"
I would like to have a piece of code I can add to the existing that will make the appropriate change at the same time.

I hope I've explained in sufficient detail.

Thanks for taking the time to help.
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,721
Members
452,667
Latest member
vanessavalentino83

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