Update multiple formulas with VBA

svjensen

Board Regular
Joined
Jun 10, 2009
Messages
118
I need to update the formulas in a number of cells (range("C12:G14")) using VBA. The formula is fairly simple, as it is just a reference to an other cell times a given value (along the lines of '=C5*Sheet2!A$1$').

I have tried doing this with the following script, but the column reference is causing me some trouble.

Code:
For c = 2 To 7
    For r = 12 To 14
        Workbooks("Mappe2").Worksheets("Ark1").Cells(r, c).Formula = "=" & c & (r-7) & "*Sheet1!$A$1"
    Next r
Next c
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Do you perhaps mean to do something along the lines of:

Code:
With Workbooks("Mapp2") 'no extension ?
    With .Worksheets("Ark1")
        .Range(.Cells(12, 2), .Cells(14, 7)).FormulaR1C1 = "=R[-7]C*Sheet1!R1C1"""
    End With
End With
 
Upvote 0
The missing extension was a typo on my part.

And yes, that is exactly was I was looking for. I am yet to become completely familiar with the R1C1 construct :-)

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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