Hi guys
I have a sheet that contains 3 columns (A,B,C). I have written the following macro and it works fine (even though I know that the syntax could be better). But I d like to make it dynamic, i.e. get rid of the cells' names ("F5:F23") and instead use something (maybe ActiveCell??) in order to be more generic. Hope that makes sense. Please have a look at the code and let me know how could I improve it and maybe what is the general logic in making a code dynamic.
Many thanks
Sub Sec3_Step2()
Range("A1").Select
Selection.End(xlToRight).Select
Selection.Offset(2, 3).Select
Selection.FormulaR1C1 = "Interval"
Selection.Offset(0, 1).Select
Selection.FormulaR1C1 = "Mean"
Selection.Offset(1, -1).Select
ActiveCell.FormulaR1C1 = "1"
Range("F5").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
Range("F5").Select
Selection.AutoFill Destination:=Range("F5:F23"), Type:=xlFillDefault
Selection.Offset(-1, 1).Select
Selection.Style = "Percent"
Selection.NumberFormat = "0.0%"
Selection.NumberFormat = "0.00%"
Selection.NumberFormat = "0.000%"
ActiveCell.FormulaR1C1 = "=SUMIF(C[-5],RC[-1],C[-4])/10000"
Selection.AutoFill Destination:=Range("G4:G23")
End Sub
I have a sheet that contains 3 columns (A,B,C). I have written the following macro and it works fine (even though I know that the syntax could be better). But I d like to make it dynamic, i.e. get rid of the cells' names ("F5:F23") and instead use something (maybe ActiveCell??) in order to be more generic. Hope that makes sense. Please have a look at the code and let me know how could I improve it and maybe what is the general logic in making a code dynamic.
Many thanks
Sub Sec3_Step2()
Range("A1").Select
Selection.End(xlToRight).Select
Selection.Offset(2, 3).Select
Selection.FormulaR1C1 = "Interval"
Selection.Offset(0, 1).Select
Selection.FormulaR1C1 = "Mean"
Selection.Offset(1, -1).Select
ActiveCell.FormulaR1C1 = "1"
Range("F5").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
Range("F5").Select
Selection.AutoFill Destination:=Range("F5:F23"), Type:=xlFillDefault
Selection.Offset(-1, 1).Select
Selection.Style = "Percent"
Selection.NumberFormat = "0.0%"
Selection.NumberFormat = "0.00%"
Selection.NumberFormat = "0.000%"
ActiveCell.FormulaR1C1 = "=SUMIF(C[-5],RC[-1],C[-4])/10000"
Selection.AutoFill Destination:=Range("G4:G23")
End Sub