Formula with active row and column reference

Charlene123

New Member
Joined
Jun 13, 2013
Messages
7
I'm trying to use a macro to insert a formula. But the formula needs to reference the current row and column. Can someone me understand how to do this?

"R[-126]C1" - should be - $a & current row
"R2C" - should be - current column & $2

"=SUMIFS([Current_Firm_OS_BP1100.xlsx]Sheet1!C10,[Current_Firm_OS_BP1100.xlsx]Sheet1!C4,"">""&R2C,[Current_Firm_OS_BP1100.xlsx]Sheet1!C4,""<""&R2C+6,[Current_Firm_OS_BP1100.xlsx]Sheet1!C3,""1024"",[Current_Firm_OS_BP1100.xlsx]Sheet1!C8,R[-126]C1)"

Also, I want to insert this formula based on column E having the text "firm orders"

THANKS in advance for any help!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
With the help I have the formula figured out, but how would I use a macro to insert it into $h1:$K1 based on $A1 being a specific text ("firm orders")
 
Upvote 0
With the help I have the formula figured out, but how would I use a macro to insert it into $h1:$K1 based on $A1 being a specific text ("firm orders")
Do you mean something like:
Code:
If Range("A1")="firm orders" Then
    Range("H1:K1").FormulaR1C1=...
End If
 
Last edited:
Upvote 0
Surprisingly I got this to work
Sub Macro24()
Dim lr As Long, i As Long
lr = Cells(Rows.Count, "E").End(xlUp).ROW
For i = 2 To lr
If (Cells(i, "E")) = "Firm Orders" Then Cells(i, "I").Resize(1, 40).FormulaR1C1 = _
"=formula"
Next i
Range("a1").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,447
Latest member
M V Arun

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