View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
pete the greek pete the greek is offline
external usenet poster
 
Posts: 17
Default inputbox type 64 (array)

thanks dave

ill try some of these i really like the split one i think i can incorperate
that

cheers pete

"Dave Peterson" wrote:

If you know how many responses to retrieve from the user, you could use:

Dim Cols As Variant
Cols = Application.InputBox("type in columns required", _
Type:=64, Default:=Array(1, 3, 5))

But this means that the user will be seeing 3 different inputboxes with this
single command.

====
You could prompt them for a string and split the response yourself:

Dim Cols As Variant
Dim resp As String
Dim iCtr As Long
resp = InputBox("type in columns require sepArated by commas ")

If resp = "" Then
Exit Sub
End If

Cols = Split(resp, ",")

For iCtr = LBound(Cols) To UBound(Cols)
'do something
MsgBox Cols(iCtr)
Next iCtr

(Split was added in xl2k--it won't work with xl97, but there is an easy fix.)

====
But if you're asking for columns, I'd try to let the user just use the mouse to
select the range:

Dim Cols As Range
Dim myRng As Range
Dim myCell As Range

Set Cols = Nothing
On Error Resume Next
Set Cols = Application.InputBox("Point at the columns you want to use", _
Type:=8)
On Error GoTo 0

If Cols Is Nothing Then
Exit Sub 'user hit cancel
End If

With Cols.Parent
Set myRng = Intersect(.Rows(1), Cols.EntireColumn)
End With

For Each myCell In myRng.Cells
MsgBox myCell.Column
Next myCell


pete the greek wrote:

i assume this will let the user input an array of values. what should the
user use as a seperater as they enter the array values.

my code is

Set cols = Application.InputBox("type in columns require seperated by
commas", Type:=64)

i get a formula error box no matter what i type in the input box i have
tried commas, space quotes


--

Dave Peterson