View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default VBA IF statements

Joanne: My 1 1/2 cents -
(1) Read the VBA Help on If-Then-Else statements, especially ElseIf, and see
if that's what you want. You might type ElseIf into the Answer Wizard and
see if the topics there help at all.
(2) What are you using Offset with Range("A1").Select? Offset moves the
selection (or active cell) from where it is to another cell relative to the
active cell - (0,1) would move it to the right one cell in the same row.
Range("A1").Select will take you from wherever you are directly to A1. You
likewise don't need it to assign ans to A1 - Range("A1") = ans will do.
(You do have Dim ans As String in the beginning of this, right?)

Ed

"Joanne Toone" wrote in message
...
I was wondering if you can do an if statement that says "if input isn't
.. then ...". Below is the code im trying to sort out, and i think
you'll understand once you see it!

ActiveCell.Offset(0, 1).Range("A1").Select
ans = Application.InputBox("Enter the customer title: ", _
"Customer Title", Type:=2) ' Type 2 for a text entry
If ans = "Miss" Or ans = "Mr" Or ans = "Ms" Or ans = "Mrs"
Then
MsgBox "Please input an appropriate title", vbOKOnly +
vbCritical, "Incorrect Input"
Application.Run "InputMe"
Exit Sub
End If
ActiveCell.Offset.Range("A1") = ans


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!