InputBox help please

L

Les Stout

Hi all, i have a range of cells K12:K17 and i need to ask the user for
input (Account Numbers) for each cell from 12 to 17, can i use one
inputbox and loop through or must i use 6 different input boxes ??
Bearing in mind the users input might only need to put in a minimuim of
two account numbers... Any help would be appreciated...
I am not a programmer but a dabbler...

Les Stout
 
G

Guest

try:
Sub myInput()
For Each x In Range("K12:K17")
x.Value = InputBox("Account ? ")
Next
End Sub


"Les Stout" skrev:
 
G

Guest

well maby this is better :

Sub myInput()
For Each x In Range("K12:K17")
x.Interior.ColorIndex = 3
y = InputBox("Account ? ", , , 40, 40)
If y <> Empty Then x.Value = y
x.Interior.ColorIndex = xlNone
Next
End Sub




"excelent" skrev:
 
L

Les Stout

Thank you excelent for an excellent answer :)

Just what i was looking for.

Les Stout
 
J

JMay

Here's some interesting code - all you have to do is enter only 1,2,3 or
4
Modify to suit
HTH,
Jim May

Post this into a New Workbook for demonstration purposes

Post below into a Standard Module:

Sub test()
Dim strInput As String
Dim arr1
Dim arr2
Dim i As Byte

'Change below line to suit your needs - Also Inputbox Values below
arr2 = Array("value 1", "value 2", "value 3", "value 4")
strInput = InputBox("Pick up to 4 of the following numbers, separated by
comma s:" & _
vbCrLf & vbCrLf & _
"1. value 1" & vbCrLf & _
"2. value 2" & vbCrLf & _
"3. value 3" & vbCrLf & _
"4. value 4" & vbCrLf & vbCrLf & _
"The corresponding values will be placed in cells
starting at column A", _
"entering values")

If Len(strInput) = 0 Or StrPtr(strInput) = 0 Then
Exit Sub
End If

Range("K12:K17").ClearContents ' I modified this

If InStr(1, strInput, ",", vbBinaryCompare) = 0 Then
Cells(1) = arr2(Val(Trim(strInput)) - 1)
Exit Sub
End If

arr1 = Split(strInput, ",")

For i = 0 To UBound(arr1)
Cells(i + 12, 11) = arr2(Val(Trim(arr1(i))) - 1) 'modified
Next
End Sub
 

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

InputBox entries & advice 16
question about the Marco inputbox. 0
Inputbox used for password 2
InputBox 3
inputbox help 1
Inputbox Verbiage 3
inputbox prompt 1
Convert code to lookup three criteria return fourth 15

Top