JasonEnsor
Programmer
Hi Guys,
I am hoping someone can shed some light on an issue I am having at the moment. I have a userform that hosts a listview control. I am wanting to loop through all cells on my worksheet and populate them in the listview control called lst (Once I have that working I will set up criteria to only populate certain values).
The code I have at the moment is
This gives me an Index out of bounds error.
if I alter my code to the following
and have the values 1 to 6 in column A, I get the numbers 2,4,6 printed then 3 blank lines on the lst control
Any ideas what is going wrong here with my code?
Any help would be appreciated
Regards
J.
I am hoping someone can shed some light on an issue I am having at the moment. I have a userform that hosts a listview control. I am wanting to loop through all cells on my worksheet and populate them in the listview control called lst (Once I have that working I will set up criteria to only populate certain values).
The code I have at the moment is
Code:
For Each Item In ws.Range("A2:A" & currentLastRow)
currentRow = Item.Row
lst.ListItems.Add lst.ListItems.count, , Item.Cells(currentRow, 1)
Next Item
This gives me an Index out of bounds error.
if I alter my code to the following
Code:
For Each Item In ws.Range("A2:A" & currentLastRow)
currentRow = Item.Row
lst.ListItems.Add lst.ListItems.count + 1, , Item.Cells(currentRow, 1)
Next Item
and have the values 1 to 6 in column A, I get the numbers 2,4,6 printed then 3 blank lines on the lst control
Any ideas what is going wrong here with my code?
Any help would be appreciated
Regards
J.