Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Waldemar Fischer   on Sep 03 In MS Office Category.

  
Question Answered By: Benjamin Simpson   on Sep 03

: Why doesn't VBA like this line  of code? I get a "Type Mismatch Error
: 13" when I try to run.
: If Worksheets("Input").Range("B9").Text = "Stationary" _
: Then SCTCode = InputBox("1 = Underwater Structure") _
: ("2 = Feeding Structure") _
: ("3 = Transfer Structure") _
: ("4 = Fixed Structure") _
: ("5 = Custom Sturcture") _
: ("Enter code  1 thru 5: ")

Do more testing. Use the VBA help system. Combine successfully
tested simple statements to form complex statements.


Test this (all one line):

InputBox("1 = Underwater Structure") ("2 = Feeding Structure") ("3 =
Transfer Structure") ("4 = Fixed Structure") ("5 = Custom Structure")
("Enter Code 1 thru 5: ")

It doesn't work on a single line, so it will not work
on multiple  lines. Place the cursor inside the word
"InputBox" and press the F1 function key. VBA help reveals
the syntax for InputBox uses only one set  of parenthesis,
not six sets. It also tells how to insert more than one
line, though it omits describing the vbCrLf constant.

Here's a working InputBox.

InputBox ( _
"1 = Underwater Structure" & vbCrLf & _
"2 = Feeding Structure" & vbCrLf & _
"3 = Transfer Structure" & vbCrLf & _
"4 = Fixed Structure" & vbCrLf & _
"5 = Custom Structure" & vbCrLf & vbCrLf & _
"Enter Code 1 thru 5:" _
)

After testing this, I can then place it into the
conditional, confident that an error will not be caused
by the input  box.


If Worksheets("Input").Range("B9").Text = "Stationary" Then
SCTCode = InputBox( _
"1 = Underwater Structure" & vbCrLf & _
"2 = Feeding Structure" & vbCrLf & _
"3 = Transfer Structure" & vbCrLf & _
"4 = Fixed Structure" & vbCrLf & _
"5 = Custom Structure" & vbCrLf & vbCrLf & _
"Enter Code 1 thru 5:" _
)
End If

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Input Box Or get search suggestion and latest updates.


Tagged: