Try this using autofill instead
Option Explicit
Sub fillinnumsSAS()
Dim ss As Worksheet
Dim ds As Worksheet
Dim slr As Long
Dim dlr As Long
Dim i As Long
Dim mc As Long
Set ss = sheets("Sheet20")
Set ds = sheets("Sheet21")
slr = ss.Cells(Rows.Count, 1).End(xlUp).Row
On Error Resume Next
For i = 2 To slr
dlr = ds.Cells(Rows.Count, 1).End(xlUp).Row
mc = ss.Cells(i + 1, 1) - ss.Cells(i, 1)
With ds
.Cells(dlr, 1) = ss.Cells(i, 1)
.Cells(dlr, 2) = ss.Cells(i, 3)
.Range(.Cells(dlr, 1), .Cells(dlr, 2)).AutoFill _
Destination:=.Range(.Cells(dlr, 1), .Cells(dlr + mc, 2))
End With
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"D. Stacy" .(remove_this_part). wrote in message
...
I have three column of data and I would like to use VBA code to go loop
thru
the rows of data and then write output to another worksheet.
Value Range Label
1400 175 Red
2400 112 Blue
9000 710 Green
The output table (range) would look something like
1400 Red
1401 Red
1402 Red
1403 Red
...
...
...
..
2400 Blue
2401 Blue
etc. etc.
Thanks in advance!