VBA Loop formula

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello all

Can I have help please on this loop please.

I want to complete a sumifs statement in cell "D9" and then replicate this every 4 cell down in column "D" until I get to cell "D2597"

Tried to put this together but failed


Code:
Dim i As Integer
Range("D9").Select
i = 1
Do Until i > 2597
    Cells(i, 1).Value = .FormulaR1C1 = "=SUMIFS('Data'!C18,'Data'!C[5],R[-1]C[-2],'Data'!C22,Sheet1!R3C4,'Data'!C23,Sheet1!R5C3)"
    i = i + 4
Loop
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
How about
Code:
Dim i As Long
For i = 9 To 2597 Step 4
   Cells(i, 4).FormulaR1C1 = "=SUMIFS('Data'!C18,'Data'!C[5],R[-1]C[-2],'Data'!C22,Sheet1!R3C4,'Data'!C23,Sheet1!R5C3)"
Next i
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Fluff at the moment this puts the formula in column 4
Is it possible to populate columns 4 to 16 with the same formula please or should I just use this loop 12 times
 
Upvote 0
Try
Code:
   Cells(i, 4).Resize(, 12).FormulaR1C1 = "=SUMIFS('Data'!C18,'Data'!C[5],R[-1]C[-2],'Data'!C22,Sheet1!R3C4,'Data'!C23,Sheet1!R5C3)"
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

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