Hi All,
I have requirement where based on inputs cells i am building one formulae and populatig the destination cols, but as number of input formulae can vary so i have written a Dynamic VBA code as below but it is throwing some error. Can someone help me out please. First i am running the VOLACAL() then DYNVOLA() , but i am getting error in DYNVOLA() as AUTOFILL METHOD OF RANGE CLASS FAILED.
I have requirement where based on inputs cells i am building one formulae and populatig the destination cols, but as number of input formulae can vary so i have written a Dynamic VBA code as below but it is throwing some error. Can someone help me out please. First i am running the VOLACAL() then DYNVOLA() , but i am getting error in DYNVOLA() as AUTOFILL METHOD OF RANGE CLASS FAILED.
Code:
Sub VolaCal()
'
' VolaCal Macro
'
'
Range("F3").Select
ActiveCell.FormulaR1C1 = "=ABS(RC[-1]-R[-1]C[-1])"
Range("G3").Select
ActiveCell.FormulaR1C1 = "=ABS(RC[-2]-RC[-5])"
Range("H3").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-6]>RC[-3],ABS(RC[-6]-RC[-4]),ABS(RC[-6]-RC[-5]))"
Range("H4").Select
Range("I3").Select
ActiveCell.FormulaR1C1 = "=POWER(RC[-3]*RC[-2]*RC[-1],1/3)"
Range("I4").Select
End Sub
Sub DynVola()
'
' DynVola Macro
'
'
Dim strRng As Long
strRng = Range("A" & Rows.Count).End(xlUp).Row
Selection.AutoFill Destination:=Sheets("Sheet2").Range("F3:I" & strRng)
Sheets("Sheet2").Range("F3:I" & strRng).Select
End Sub