TomNR
Member
Hi all,
I am looking for some guidance.
I basically have a Userform where you search for a member of staff, which pulls all of the tasks assigned to that specific staffs (across four Worksheets) into a List Box (I have this working)
But when you click on one of the actions in the list box it is supposed to populate the Userform.
However, I am running into an issue with it populating the User form with the data from the multiple worksheets. I have tried For Each ws In ThisWorkbook.Worksheets but this isn't resolving the issue?
Any help would be appreciated!
Mod Edit: Code Tags added
I am looking for some guidance.
I basically have a Userform where you search for a member of staff, which pulls all of the tasks assigned to that specific staffs (across four Worksheets) into a List Box (I have this working)
But when you click on one of the actions in the list box it is supposed to populate the Userform.
However, I am running into an issue with it populating the User form with the data from the multiple worksheets. I have tried For Each ws In ThisWorkbook.Worksheets but this isn't resolving the issue?
Any help would be appreciated!
Code:
Private Sub lstLookup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'declare the variables
Dim cUID As String
Dim I As Integer
Dim findvalue
Dim ws As Worksheet
'get the select value from the listbox
For I = 0 To lstLookup.ListCount - 1
If lstLookup.Selected(I) = True Then
cUID = lstLookup.List(I, 0)
End If
Next I
For Each ws In ThisWorkbook.Worksheets
Set findvalue = ws.Range("D:D").Find(What:=cUID, LookIn:=xlValues).Offset(0, -3)
Next ws
'add the database values to the userform
cNum = 8
For X = 1 To cNum
Me.Controls("reg" & X).Value = findvalue
Set findvalue = findvalue.Offset(0, 3)
Next
'disable adding
Me.cmdAdd.Enabled = False
Exit Sub
End Sub
Mod Edit: Code Tags added