VBA excel传递回参数
好的,我想给这个宏添加一些东西VBA excel传递回参数,vba,excel,Vba,Excel,好的,我想给这个宏添加一些东西 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 i
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
这种情况是这样的,我希望我的sub通过 搜索()到getInput(),然后getInput()将找到的参数返回到 搜索()
我是否应该添加类似搜索的内容(ByVal被发现为布尔值)?如果您想返回值,那么您应该将getInput子函数更改为函数,因为它们可以返回值
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
您的
getInput
子系统中的a
是什么?循环语法无效。函数可以返回值。你试过了吗?