VBA excel Passing back parameter
excel, vba
Solution
if you want to return a value, then you should change the getInput Sub to a function as they can return values.
Sub Search()
Dim found As Boolean
InputBox myInput
found = checkInput(myInput)
If found = False Then
'DO something
End If
End Sub
Function checkInput(inputVar As String) As Boolean
Dim result As Boolean
'do your checking here and set result
'return the result
checkInput = result
End Function
Problem
Okay I want to add something to this macro ``` Sub Search() Inputbox myInput found = false loop Call getInput (myInput) '~> check multiple files end loop If found = false 'DO something End if End sub Sub getInput(ByVal inputVar As String, ByVal Input as Boolean) If a = inputVar Then found = true '~> I want to pass this parameter back to search End If End sub ``` The case is like, I want my sub to pass the found parameter from Search() to getInput() and then getInput() return the found parameter to Search() Should I add something like search(ByVal found as boolean) ?