jardenp
Active Member
- Joined
- May 12, 2009
- Messages
- 373
- Office Version
- 2019
- 2016
- 2013
- 2011
- 2010
- Platform
- Windows
I am using an InputBox to ask for variable AcctSelect. I want to set up a simple If Then statement to test if AcctSelect is either 1) "A" or "B" or 2) something else and then exit sub. I need to use the variable later for column selection and anything other than "a" or "b" would throw an error. Case is not important. Something like this, with the red parts replaced by actual code that does what's described:
Also, I know I could loop it back to the InputBox, but I'd like it to exit the sub if it's neither "A" nor "B" (again, if it matters, it's not case-sensitive).
Thanks!
Josh in IN
Code:
dim AcctSelect as String
AcctSelect = InputBox("Enter A or B")
IF [COLOR=#ff0000](AcctSelect = "A" OR AcctSelect = "B") [/COLOR]Then[INDENT]Range("A1").Select[/INDENT]
Else
[INDENT]MsgBox "Please rerun macro and enter ""A"" or ""B"""
Exit Sub[/INDENT]
End If
Thanks!
Josh in IN