Good approach…
As to get the code and the idea right I like to stick first to the inputbox-code. I will give the –more prefered- userform idea some thoughts later on.
As to the code looked for… I was thinking of something like this.
Sub SearchWorkbook()
Dim What, When, Who As String
Dim sht As Worksheet
Dim Found As Range
Dim FirstAddress As String
Dim Response As Boolean
What = InputBox("Vul hieronder de naam van de werkeenheid/afdeling in waarvoor je vervang nodig hebt:")
When = InputBox("Vul hier de dag van de maand in (enkel het nummer van de dag) waarvoor je vervang zoekt:")
Who = InputBox("Vul hier de functie in die benodigd is")
If What = "" Then Exit Sub
If When = "" Then Exit Sub
If Who = "" Then Exit Sub
For Each sht In Worksheets
sht.Activate
If UCase(Cells(When + 14, 3)) <> "NIET" Then
If UCase(Cells(When + 14, 4)) <> "X" Then
If Ucase(Cells(4, 7))= Who
End If
End If
Set Found = sht.Range("D6").Find(What, LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)
If Not Found Is Nothing Then
FirstAddress = Found.Address
Do
Found.Activate
Response = MsgBox("Doorgaan?", vbYesNo + vbQuestion)
If Response = vbNo Then Exit Sub
Set Found = Cells.FindNext(After:=ActiveCell)
If Found.Address = FirstAddress Then Exit Do
Loop
End If
End If
Next sht
MsgBox "Het zoeken is beëindigd!"
End Sub
I tried a few things regarding the line > If Ucase(Cells(4, 7))= Who Then
< and it seems that the code regarding the Who-input is ignored whatever I try. Another thing is that as soon as I add another if statement I get a message “Next without for”. I could solve this by adding another “end If” but I’m not sure if that’s right.
Finally the line > If Response = vbNo Then Exit Sub< does not seem to work and could be a language conflict???!!!