Hello,
I am using the sub below to populate a listbox (named "RepairHistory") that I have embedded in a worksheet, the code works fine but the issue is that every time I run the macro the listbox moves a few pixels up and to the left. I do not understand why it is doing that, has anyone ever had this issue before? I need to stop this from happening so I appreciate any insights - thanks,
I am using the sub below to populate a listbox (named "RepairHistory") that I have embedded in a worksheet, the code works fine but the issue is that every time I run the macro the listbox moves a few pixels up and to the left. I do not understand why it is doing that, has anyone ever had this issue before? I need to stop this from happening so I appreciate any insights - thanks,
VBA Code:
Sub RepairHistoryButton_Click()
Dim sh As Object, sh2 As Worksheet
Dim i As Long
Set sh = Sheets("Plant Status")
Set sh2 = Sheets("Repair Log")
sh.RepairHistory.Clear
For i = 1 To sh2.Range("A" & Rows.Count).End(3).Row
If sh2.Range("A" & i).Value = sh.RepairedDevice.Value Then
With sh.RepairHistory
.AddItem
.List(.ListCount - 1, 0) = sh2.Cells(i, 2).Value
.List(.ListCount - 1, 1) = sh2.Cells(i, 3).Value
.List(.ListCount - 1, 2) = sh2.Cells(i, 4).Value
.List(.ListCount - 1, 3) = sh2.Cells(i, 5).Value
.List(.ListCount - 1, 4) = sh2.Cells(i, 6).Value
.List(.ListCount - 1, 5) = i
End With
End If
Next
End Sub