VBA to Copy/Paste Formula Into Next Cell (Column)

Gerwe1988

New Member
Joined
Mar 21, 2022
Messages
10
Office Version
  1. 2019
Platform
  1. Windows
Hello everyone,

I'm new to macros and need some assistance with establishing a code for my forecast file. The macro will scan row 3 for the current "reporting" month, to decide which column to update (AS). The macro will then copy & paste the prior months formula from one cell to next, into the current "reporting" month. The prior months formula will need to be hard coded. There are certain rows that need to be updated in this process (Rows 16,17, 27, 28). For example, row 16 "New patients", the prior months formula (Jan-22, AR16), will be copied and pasted into the next column (AS16). The prior months formula (AR16) will be hard coded. Thanks in advance!
 

Attachments

  • Example.JPG
    Example.JPG
    97.9 KB · Views: 21
Sorry, each tab/worksheet has formulas in different columns and rows. Could you provide an example on how the macro above would be modified to accompany different range/columns? The "reporting" identifier is static and on row 3 on all tabs.
are all the formulas your talking in various sheets won't change? if so, would it possible to make an inventory of all your sheet and note on what row and/or columns address of your "formulas"?
that way we can encapsulate the code with an "if sheetname = sheet1_Set_A" statement.
Let say if condition are met based on your noted cell address for each sheet you can then make a variable that correspond to that sheet name with "cell address" different from the other sheet!

ie. if sheetname = employee then
use the code with range address for employee sheet (A1:B100)
if sheetname = salary then
use the code range address for address sheet (B101:C100) and so on based on your different sheet!

if that's not possible or if you can't do that then you do it the hard way! create multiple instance of the code for different sheet
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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