I’m trying to add the items from a list to some rows in an Excel Sheet.
I tried to do it this way:
Dim Rand As Long
Dim ws As Worksheet
Set ws = Worksheets("Necmontage")
Rand = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Range(ws.Cells(Rand, 1), ws.Cells(Rand + necesar.ListCount - 1, 1)).Merge
ws.Cells(Rand, 1) = "K"
Range(ws.Cells(Rand, 2), ws.Cells(Rand + necesar.ListCount - 1, 2)).Merge
ws.Cells(Rand, 2) = "Montage"
Range(ws.Cells(Rand, 3), ws.Cells(Rand + necesar.ListCount - 1, 3)).Merge
ws.Cells(Rand, 3) = comanda.Caption
Dim i As Integer
i = 0
Do While i = necesar.ListCount - 1
ws.Cells(Rand + i, 4) = necesar.List(i, 0)
i = i + 1
Loop
End Sub
It adds all the values I want except the values from the List (where I do that While Loop). I don’t know why but it doesn’t take the values. Any idea about this problem?
Did you mean in your code:
Btw, you can see in debug mode by putting a breakpoint on the
Do Whileline if the program goes where you wanted it to.