Hi All,
I Have a userform with a listbox on it called Listbox2 which is populated by the user, this form works ok. In this list box there will be entries such as:
R001
R003
R004.
What i then want to do is scroll down row 14 of sheet 1 looking for any entries of R001 (there will be multiple rows) and copy them on to a new sheet. then loop and put all entries of R003 underneath and so on.
This is the code i have so far which doesn't work and is probably useless:
Dim i As Integer, x As Integer, y As Integer
Dim shAL As Worksheet
Dim shIS As Worksheet
Set shIS = Sheets("Individual Statements")
Set shAL = Sheets("Account Listings")
y = 1
i = 8
x = 1
Do While y < Me.ListBox2.ListCount
If Me.ListBox2.List = shAL.Cells(i, 14) Then
Do While shAL.Cells(i, 14) = Me.ListBox2.List
shAL.Rows(i).Select
Selection.Copy
shIS.Rows(x).Select
Selection.Paste
i = i + 1
x = x + 1
Loop
Else
y = y + 1
End If
Loop
End Sub
Any help would be greatly appreciated as i have been trying for 6 hours!!!!
Thanks in advance
Tom
I Have a userform with a listbox on it called Listbox2 which is populated by the user, this form works ok. In this list box there will be entries such as:
R001
R003
R004.
What i then want to do is scroll down row 14 of sheet 1 looking for any entries of R001 (there will be multiple rows) and copy them on to a new sheet. then loop and put all entries of R003 underneath and so on.
This is the code i have so far which doesn't work and is probably useless:
Dim i As Integer, x As Integer, y As Integer
Dim shAL As Worksheet
Dim shIS As Worksheet
Set shIS = Sheets("Individual Statements")
Set shAL = Sheets("Account Listings")
y = 1
i = 8
x = 1
Do While y < Me.ListBox2.ListCount
If Me.ListBox2.List = shAL.Cells(i, 14) Then
Do While shAL.Cells(i, 14) = Me.ListBox2.List
shAL.Rows(i).Select
Selection.Copy
shIS.Rows(x).Select
Selection.Paste
i = i + 1
x = x + 1
Loop
Else
y = y + 1
End If
Loop
End Sub
Any help would be greatly appreciated as i have been trying for 6 hours!!!!
Thanks in advance
Tom