How to Auto FIll formula with dynamic range

Warpug

New Member
Joined
Apr 13, 2017
Messages
19
Office Version
  1. 365
Platform
  1. Windows
So I am currently working on a sheet into which I would like to place this formula into cell Q6.
=ROUND(SUMIFS($P$6:$P$97,$H$6:$H$97,$H6),2)=0
what I am trying to figure out, is how do write this in vba so that it enters the formula in all the column q for every row. So the issue is that the p97 and h97 are dynamic and change regularly. Thank you.
Sub QFill()
ActiveCell.FormulaR6C17 = "=ROUND(SUMIFS(R6C16:R97C16,R6C8:R97C8,RC8),2)=0"
Range("Q6").Select
Selection.AutoFill Destination:=Range("Q6:Q97")
Range("Q6:Q97").Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
How about
Code:
Sub Warpug()
   Dim UsdRws As Long
   UsdRws = Range("P" & Rows.Count).End(xlUp).Row
   Range("Q6:Q" & UsdRws).FormulaR1C1 = "=ROUND(SUMIFS(R6C16:R" & UsdRws & "C16,R6C8:R" & UsdRws & "C8,RC8),2)=0"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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