Dim str1 As String
Dim y As Integer
Dim x As Integer = 0
Dim z As Integer
For i As Integer = 0 To DataGridView1.Rows.Count - 1 Step +1
Dim a As Integer = 1
x = y
str1 = DataGridView1.Rows(i).Cells(0).Value
z = DataGridView1.Rows(i).Cells(1).Value
y = z
For j As Integer = x To (x + (y - 1))
DataGridView2.Rows(j).Cells(1).Value = str1
DataGridView2.Rows(j).Cells(2).Value = a
a += 1
Next
Next
в этом коде внешний цикл for принимает только первую и последнюю строку datagridview1 ..