A
AMK4
I'm trying to verify input given via an input box:
Code
-------------------
Sub copyData()
Dim varNameInput As String
myNameInput = Application.InputBox(prompt:="Enter a sheet name", _
Title:="Sheet Name", Type:=2)
Do While myNameInput = ""
MsgBox "You didn't enter a sheet name!", 16
myNameInput = Application.InputBox(prompt:="Enter a sheet name", _
Title:="Sheet Name", Type:=2)
Loop
If Not myNameInput = False Then
MsgBox myNameInput
End If
Exit Sub
End Su
-------------------
This works, however... Because I can't quite translate what's in m
mind into VBA, I'm stuck with the following cases which should al
trigger a failure MsgBox and repeat the loop:
- If the user enters a white space
- If the user enters a name with a white space
- If the user enters a name that doesn't match any of the sheets i
the workbook.
The latter, if I'm not mistaken, I need to do with Intersect, somethin
like (and please correct me if I'm wrong here):
Code
-------------------
If Not Intersect(myNameInput, Range("A1:A10")) is Nothing Then
... successful match, run necessary code ...
Else
... trigger failure again and go back to loop ...
End I
-------------------
I just don't know how to translate that into VBA.
And on a slightly different note, can an evaluation contain ORs? Fo
example, *If (myNameInput = "" || myNameInput = False || ...etc.) Then
Code
-------------------
Sub copyData()
Dim varNameInput As String
myNameInput = Application.InputBox(prompt:="Enter a sheet name", _
Title:="Sheet Name", Type:=2)
Do While myNameInput = ""
MsgBox "You didn't enter a sheet name!", 16
myNameInput = Application.InputBox(prompt:="Enter a sheet name", _
Title:="Sheet Name", Type:=2)
Loop
If Not myNameInput = False Then
MsgBox myNameInput
End If
Exit Sub
End Su
-------------------
This works, however... Because I can't quite translate what's in m
mind into VBA, I'm stuck with the following cases which should al
trigger a failure MsgBox and repeat the loop:
- If the user enters a white space
- If the user enters a name with a white space
- If the user enters a name that doesn't match any of the sheets i
the workbook.
The latter, if I'm not mistaken, I need to do with Intersect, somethin
like (and please correct me if I'm wrong here):
Code
-------------------
If Not Intersect(myNameInput, Range("A1:A10")) is Nothing Then
... successful match, run necessary code ...
Else
... trigger failure again and go back to loop ...
End I
-------------------
I just don't know how to translate that into VBA.
And on a slightly different note, can an evaluation contain ORs? Fo
example, *If (myNameInput = "" || myNameInput = False || ...etc.) Then