- Joined
- Jul 25, 2007
- Messages
- 26
- Reaction score
- 0
Hello to All,
Can anyone please help me. I have two columns Say "C" & "D". "D" has data entered down for a variable number of rows. I wish to enter a formula in "C2" and fill it down for the same number of rows that "D" has data entered. I am using the following code.
Sub FillDownFourPlayerB()
Dim lngLastRow As Long
Dim fillRange
Dim ActiveWorksheets
Dim SourceRange
Dim RangeSelection
Worksheets("4 Player Team").Range("C2").FormulaR1C1 = "='League Players List'!RC[-1]"
lngLastRow = Range("D" & Rows.Count).End(xlUp).Row
Cells(lngLastRow - 0, 3).Select
With ActiveCell
'The following line works if there is 33 rows (Counting header row) with data entered. I need a better way. Some variable way.
Range(.Cells(0, 1), .Cells(-31, 1)).Select
End With
Selection.FillDown
With Selection
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End With
Range("F1").Select
End Sub
Hopefully thanks in advance
GeoffreyBarnard
Can anyone please help me. I have two columns Say "C" & "D". "D" has data entered down for a variable number of rows. I wish to enter a formula in "C2" and fill it down for the same number of rows that "D" has data entered. I am using the following code.
Sub FillDownFourPlayerB()
Dim lngLastRow As Long
Dim fillRange
Dim ActiveWorksheets
Dim SourceRange
Dim RangeSelection
Worksheets("4 Player Team").Range("C2").FormulaR1C1 = "='League Players List'!RC[-1]"
lngLastRow = Range("D" & Rows.Count).End(xlUp).Row
Cells(lngLastRow - 0, 3).Select
With ActiveCell
'The following line works if there is 33 rows (Counting header row) with data entered. I need a better way. Some variable way.
Range(.Cells(0, 1), .Cells(-31, 1)).Select
End With
Selection.FillDown
With Selection
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End With
Range("F1").Select
End Sub
Hopefully thanks in advance
GeoffreyBarnard