Input box for multiple entries

M

Munchkin

Is it possible to have one input box that asks 1-4 questions, then take the
user answer & plunk them ins a desired cell?

Or is only 1 questions per input box allowed?
 
J

Jim Thomlinson

If you have 4 questions I would be more inclined to use a User Form with 4
text boxes. One input box askes only one question. In a form you can embed as
many questions as you want...
 
J

JLGWhiz

I think it is better expressed that the Inputbox will only return one value.
Why not explain what your objective is and maybe someone can offer a
solution?
 
J

john

It can be done using a couple of arrays & a function but as Jim has already
stated, userform would be easier.

However, if you want to pursue the inputbox idea then try the following as
an approach - it asks six questions which are stored in an array. I have
displayed these values in msgbox but you would use them as required in your
application.

Post all code in standard module (not fully tested)

Dim Title As String
Sub EnterData()
Dim myarray(6) As Variant
Dim Entryarray()

Title = "Enter Company Data"

Entryarray = Array("Company Name", _
"Address", _
"Telephone No", _
"Business Sector", _
"Contact Name", _
"Contact Email")

i = 0

Do
'msgbox msg shown
when
'value set to 1
(required entry)
'inputbox prompt 'set to 0 when
blank entry valid
myarray(i) = get_Input("Enter " & Entryarray(i), Entryarray(i), 1)

If myarray(i) = False Then Exit Sub

i = i + 1

Loop Until i > 5

'sample code to show array data
i = 0

Do

MsgBox myarray(i)

i = i + 1

Loop Until i > 5

End Sub

Function get_Input(msg, entry, eflag)
Rem eflag determines whether the prompt msgbox
Rem is displayed when nothing is input

label:

userin = Application.InputBox(msg, Title)

If userin = False Then

msg1 = MsgBox("You pressed CANCEL - Do you want to Exit?", 292, Title)

If msg1 = 7 Then

GoTo label

Else

Exit Function

End If

ElseIf userin = "" And eflag = 1 Then

Prompt = MsgBox("Nothing Input!" & Chr(10) & entry & " MUST be
Entered", 48, entry)

GoTo label

End If

get_Input = userin

End Function

Hope helpful
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top