ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Input box for multiple entries (https://www.excelbanter.com/excel-programming/428955-input-box-multiple-entries.html)

munchkin

Input box for multiple entries
 
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?

Jim Thomlinson

Input box for multiple entries
 
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...
--
HTH...

Jim Thomlinson


"Munchkin" wrote:

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?


JLGWhiz[_2_]

Input box for multiple entries
 
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?


"Munchkin" wrote in message
...
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?




John

Input box for multiple entries
 
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


--
jb


"Munchkin" wrote:

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?



All times are GMT +1. The time now is 12:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com