having an inputbox more than once in a dialog

  • Thread starter Thread starter MOnika
  • Start date Start date
M

MOnika

Sub inpBox()

Dim fn As String
Dim wb As Workbook
Dim Target As Range
Dim sTargetValue As String
fn = Application.GetOpenFilename()
Set wb = Workbooks.Open(fn)

Set Target = Application.InputBox("Select A
cell...", , , , , , , 8)
sTargetValue = Target.Resize(1, 1).Value

End Sub

using the code above I can have an inputbox where i accept
the range from the user. Can I have more than one inputbox
in the same dialog box. My idea is to ask the user for 5
values from a workbook. SO instead of popping the inputbox
5 times I want it to appear in the same dialog box 5
times.

I hope i am clear

thanks a lot.
 
You can have multiple refedit controls on a userform. They are used to
return a cell or range address.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
Hi Bob,

Thanks a lot for the response.
I havent used refedit controls before... Can u give me a
small example to quote how its used.

thanks for your feedback.
monika
 
MOnika,
Something like the following might work for you...
'---------------------------
Sub TestInput()
Dim x As Range
Dim y As Range
Dim z As String

On Error Resume Next
Set x = Application.InputBox("Press Ctrl key and select 5 cells", _
"Test Input", , , , , , 8)
On Error GoTo 0

If Not x Is Nothing Then
If x.Areas.Count <> 5 Then
MsgBox "Need 5 cells selected"
Else
For Each y In x.Areas
z = z & y(1, 1).Value & vbNewLine
Next 'y
MsgBox z
End If
Else
MsgBox "Please try again"
End If
Set x = Nothing
Set y = Nothing
End Sub
'------------------------------------
Regards,
Jim Cone
San Francisco, CA
 

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

Back
Top