Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Use For loop to fill a range

Sub FillRange3()     Dim StartVal As Long     Dim NumToFill As Long     Dim CellCount As Long     StartVal = 2     NumToFill = 5     For CellCount = 1 To NumToFill         ActiveCell.offset(CellCount - 1, 0) = StartVal + CellCount - 1     Next CellCount End Sub