Greetings, I have been using userforms for years and I have really enjoyed it - but I have never really tried to put the technique (other than adding command buttons) directly on the worksheets. So I am trying my hand at building a dashboard and I thought that this would be the perfect time to start embedding the controls into the WS instead of calling up a userform. I now realize though that the syntax must be different as the code below is not acting the same as it does in my userform.
Briefly, I use the value in a combobox (RepairedDevice) to sort data and pass it to a listbox (RepairHistory). Works great in my userforms, but nothing really appears to happen other than moving to the Repair Log sheet. I would normally put the code in a module, but I found that I actually had to put it into the WS page module instead for it to even see the objects.
Is it that I am using the objects incorrectly and that the syntax is completely different - or am I missing something simple? Because the code is in the Dashboard WS but the data is in the Repair Log WS leads me to think that I cant pass data between sheets or something like that.
I appreciate your thoughts on this - thank you,
Briefly, I use the value in a combobox (RepairedDevice) to sort data and pass it to a listbox (RepairHistory). Works great in my userforms, but nothing really appears to happen other than moving to the Repair Log sheet. I would normally put the code in a module, but I found that I actually had to put it into the WS page module instead for it to even see the objects.
Is it that I am using the objects incorrectly and that the syntax is completely different - or am I missing something simple? Because the code is in the Dashboard WS but the data is in the Repair Log WS leads me to think that I cant pass data between sheets or something like that.
I appreciate your thoughts on this - thank you,
VBA Code:
Sub DashboardRepairs()
Dim i As Long
Dim Lastrow As Long
Application.DisplayAlerts = False
Sheets("Repair Log").Select
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow
If Cells(i, 1).Value = RepairedDevice.Value Then RepairHistory.AddItem Cells(i, 1).Value & " - " + Cells(i, 2).Value & _
" - " + Cells(i, 3).Value & " - " + Cells(i, 4).Value & " - " + Cells(i, 5).Value
Next
Sheets("Dashboard").Select
Application.DisplayAlerts = True
End Sub