Tony Chavez
04-02-2022, 07:21 AM
How to fix or develop a code for auto complete formula in each column according with the size of my table information?
i was trying to fix with different codes before but not worked. I have to change cells numbers manually, so here is my code:
Sub Formulas_new_sheet()' Cambiar los rangos acorde al numero de filas usadas
' Formula Costo unitario
Range("D2").Select
ActiveCell.Formula = "=C2/B2"
'ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D7"), Type:=xlFillDefault
Range("D2:D7").Select
'________________________
' Formula de extra / ganancia
Range("E2").Select
' Variar según el porcentaje de ganancia que se busca
ActiveCell.Formula = "=D2+(D2*0.55)"
Selection.AutoFill Destination:=Range("E2:E7"), Type:=xlFillDefault
Range("E2:E7").Select
'______________________________________
'Formula para precio de venta c/u
Range("G2").Select
ActiveCell.Formula = "=E2+F2"
Range("G2").Select
Selection.AutoFill Destination:=Range("G2:G7"), Type:=xlFillDefault
Range("G2:G7").Select
End Sub
Thank you in advanced
i was trying to fix with different codes before but not worked. I have to change cells numbers manually, so here is my code:
Sub Formulas_new_sheet()' Cambiar los rangos acorde al numero de filas usadas
' Formula Costo unitario
Range("D2").Select
ActiveCell.Formula = "=C2/B2"
'ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-2]"
Range("D2").Select
Selection.AutoFill Destination:=Range("D2:D7"), Type:=xlFillDefault
Range("D2:D7").Select
'________________________
' Formula de extra / ganancia
Range("E2").Select
' Variar según el porcentaje de ganancia que se busca
ActiveCell.Formula = "=D2+(D2*0.55)"
Selection.AutoFill Destination:=Range("E2:E7"), Type:=xlFillDefault
Range("E2:E7").Select
'______________________________________
'Formula para precio de venta c/u
Range("G2").Select
ActiveCell.Formula = "=E2+F2"
Range("G2").Select
Selection.AutoFill Destination:=Range("G2:G7"), Type:=xlFillDefault
Range("G2:G7").Select
End Sub
Thank you in advanced