Thread: display columns
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default display columns

There are many ways to address ranges, but the following code may give you a
start.


Dim R As Range
With Worksheets("Sheet1")
Set R = .Range("A1, C1, E1")
R.EntireColumn.Hidden = True
' OR
Set R = Application.Union( _
.Cells(1, 1), .Cells(1, 3), .Cells(1, 5))
R.EntireColumn.Hidden = True
End With



--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"mwam423" wrote in message
...
greetings, i have macro which runs query on database with over 100
columns.
when macro is finished i want to display only those columns i've run the
query on, anywhere from two to twenty columns.

therefore i hide all the columns of database and have a range which lists
each column to display by number (col A =1, col B = 2, etc.) what type
of
code would i use to display the columns.

have used "EntireColumn.Hidden = false" but only seems to work for single
column at a time, which would work with a loop. but i'm hoping there's
some
code that would unhide all the columns at once, any help greatly
appreicated.