patrasgabriela
New Member
- Joined
- May 9, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello,
I have created a Macro that uses a variable count the rows in order to copy paste a formula from Cell 2 of that column on all rows and it works perfectly when the range is made from multiple rows, but doesn't work if the range is just one row. The macro gets stuck at when reading the range. Is there a way to make this work? Below my macro. Thank you in Advance for your help.
I have created a Macro that uses a variable count the rows in order to copy paste a formula from Cell 2 of that column on all rows and it works perfectly when the range is made from multiple rows, but doesn't work if the range is just one row. The macro gets stuck at when reading the range. Is there a way to make this work? Below my macro. Thank you in Advance for your help.
VBA Code:
Sub workPF()
lRow = Range("A" & Rows.Count).End(xlUp).Row
Range("AI2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-10]>0,RC[-8]/(RC[-13]*RC[-9]*RC[-10]),RC[-8]/(RC[-13]*RC[-9]))"
Range("AI2").AutoFill Destination:=Range("AI2:AI" & lRow), Type:=xlFillDefault
End sub