upendra2206
New Member
- Joined
- Jul 17, 2016
- Messages
- 44
This is a part of my code:
The purpose is to go to the first empty cells in the row 2 and row 3 and then type specific formulas and then autofill in that particular column.(here from L3 to L13)
Sub AutofillTable1()
'go the first empty cell in the 2nd row and type Median
Range("IV2").End(xlToLeft).Offset(0, 1).Select 'go the first empty cell in the 2nd row and type Median
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Median"
'go the first empty cell in the 3nd row and type the formula
Range("IV3").End(xlToLeft).Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=PERCENTILE(RC[-10]:RC[-2],0.5)"
'Autofill the formula from the last filled cell in 3rd row i.e. L3 to the last filled row as per A3.
Range("IV3").End(xlToLeft).AutoFill destination:=Range("L3:L" & Range("A3").End(xlDown).Row)
End Sub
The problem is that I want to make the bold part in the code to be dynamic. i.e it may not always be L column. It may vary.
Also, There is another table with the same format and formula but different references. Now I want to carry out the same operation i.e. go to the first empty cells in the row 24 and row 25 and then type specific formulas and then auto fill in that particular column.(here from L25 to L35)
Sub AutofillTable1()
'go the first empty cell in the 24th row and type Median
Range("IV24").End(xlToLeft).Offset(0, 1).Select 'go the first empty cell in the 2nd row and type Median
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Median"
'go the first empty cell in the 3nd row and type the formula
Range("IV25").End(xlToLeft).Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=PERCENTILE(RC[-10]:RC[-2],0.5)"
'Autofill the formula from the last filled cell in 25th row i.e. L25 to the last filled row as per A24.
Range("IV25").End(xlToLeft).AutoFill destination:=Range("L25:L" & Range("A25").End(xlDown).Row)
End Sub
Can Replace the Column Reference i.e. L to a dynamic reference?
Thanks in Advance
The purpose is to go to the first empty cells in the row 2 and row 3 and then type specific formulas and then autofill in that particular column.(here from L3 to L13)
Sub AutofillTable1()
'go the first empty cell in the 2nd row and type Median
Range("IV2").End(xlToLeft).Offset(0, 1).Select 'go the first empty cell in the 2nd row and type Median
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Median"
'go the first empty cell in the 3nd row and type the formula
Range("IV3").End(xlToLeft).Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=PERCENTILE(RC[-10]:RC[-2],0.5)"
'Autofill the formula from the last filled cell in 3rd row i.e. L3 to the last filled row as per A3.
Range("IV3").End(xlToLeft).AutoFill destination:=Range("L3:L" & Range("A3").End(xlDown).Row)
End Sub
The problem is that I want to make the bold part in the code to be dynamic. i.e it may not always be L column. It may vary.
Also, There is another table with the same format and formula but different references. Now I want to carry out the same operation i.e. go to the first empty cells in the row 24 and row 25 and then type specific formulas and then auto fill in that particular column.(here from L25 to L35)
Sub AutofillTable1()
'go the first empty cell in the 24th row and type Median
Range("IV24").End(xlToLeft).Offset(0, 1).Select 'go the first empty cell in the 2nd row and type Median
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Median"
'go the first empty cell in the 3nd row and type the formula
Range("IV25").End(xlToLeft).Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=PERCENTILE(RC[-10]:RC[-2],0.5)"
'Autofill the formula from the last filled cell in 25th row i.e. L25 to the last filled row as per A24.
Range("IV25").End(xlToLeft).AutoFill destination:=Range("L25:L" & Range("A25").End(xlDown).Row)
End Sub
Can Replace the Column Reference i.e. L to a dynamic reference?
Thanks in Advance
Last edited: