View Single Post
  #5   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)

hi jim thanks for this i still get errors how should the user type the column
in the input book
a:a or 1 what would they used to seperate muiltiple columns as they input them

what i am trying to achieve is i have a 220 column spreadsheet and would
like to be able to ask the user which columns they would like to see and hide
the rest. i can do this by manually creating the array "cols" but thought the
input box would make it more flexible

Set rng = ActiveSheet.UsedRange
lastcol = rng.Columns.Count
lastrow = rng.Rows.Count
cols = Array(2, 56, 79, 122, 165)
rng.Columns.Hidden = True
For Each zz In cols
ActiveSheet.Columns(zz).Hidden = False


Next zz

"Jim Cone" wrote:

Sub ArrayWay()
Dim cols As Variant
'cols is a Variant containing an array of the values in the selection.
cols = Application.InputBox("Select the columns required ", Type:=64)
'Only one of the following will work depending on the selection.
MsgBox cols(1) 'single row
MsgBox cols(1, 1) 'multiple columns
End Sub

Sub RangeWay()
Dim cols As Excel.Range
'cols is a Range object
Set cols = Application.InputBox("Select the columns required ", Type:=8)
'Both of these will work
MsgBox cols(1)
MsgBox cols(1, 1)
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"pete the greek"

wrote in message
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