The goal is whenever I type a manager name on the textbox; it will search manager on all sheets then load all of the username who reports to the manager on the checkbox caption. The below codes works to find and load values to only one sheets. However sometimes, I have more than 1 sheet (This exclude the main sheet).
File
Sheet 2 (Employee):
username | first | last | manager | role | status
HAkon | Howard | Akon | Don Kong | User |
JCorny1 | Jones | Corny | Don Kong | User |
HMighty | Howard | Mighty | Jack Ben | Manager |
Sheet 3 (Contractor):
username | first | last | manager | role | status
DNygen | Dong | Nygen | Don Kong | User |
LNygen | Lee | Nygen | Don Kong | User |
Sheet 4 (Service):
username | first | last | manager | role | status
BFinney | Barney | Finney | Don Kong | User |
CKon | Carillo | Kon | Luz Kurt | Rookie |
Codes for 1 sheet only
Call Clearall
Dim gui As Worksheet
Dim AR As Worksheet
Dim getfind As String
Dim qq As Range
Dim i As Long
Set gui = Sheets("GUI")
Set AR = Sheets("Employee")
For cv = 1 To 40
cbv(cv) = ""
Next cv
Set gui = Sheets("GUI")
Set AR = Sheets("Employee")
'get value from search
'MsgBox gui.OLEObjects("InputSearch").Object.Value
getfind = gui.OLEObjects("InputSearch").Object.Value
'get count result of finding
rcount = 0
rcount = rcount + Application.WorksheetFunction.CountIf(AR.Range("D:D"), getfind)
'With AR.Range("D:D")
'Set qq = .Find(what:=getfind, LookIn:=xlValues, Lookat:=xlPart)
'If Not qq Is Nothing Then
'firstaddress = qq.Address
'Do
'For x = 1 To rcount
'Set qq = .FindNext(qq)
'y = qq.Address
'Caption'
'gui.OLEObjects("cb" & x).Object.Caption = x & ". " & AR.Range(y).Offset(0, -2).Value & " " & AR.Range(y).Offset(0, -1).Value & " (" & AR.Range(y).Offset(0, -3).Value & ")"
'unhide combobbox
'gui.OLEObjects("cb" & x).Visible = True
'unhide textbox
'gui.OLEObjects("TextBox" & x).Visible = True
'Next x
'Loop While Not qq Is Nothing And qq.Address <> firstaddress
'End If
'End With
What I tried and did not work was I set the 'for n = 1 to sheets.count' above code 'With AR.Range("D:D")', set all 'AR.Range' to 'Sheets(n).Range', then put 'next n' after 'End with'. This only grabs the last person of the sheets it finds then replace it on all checkboxes.
Bookmarks