Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default display columns

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default display columns

Hi

For instance: Range("A1,C1,F1").EntireColumn.Hidden = True

But a small loop is not so inefficient in this case.

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"mwam423" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default display columns

hi wigi and chip, i was hoping there was a way i could use the column numbers
en masse. yes, am using a loop and that works fine as the query rarely needs
to display more than twenty columns. appreciate the responses!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
display columns alphabetically Grocer New Users to Excel 0 September 21st 09 06:51 PM
Compare columns and display the value Raj Excel Discussion (Misc queries) 1 December 29th 08 09:49 AM
display only columns A to I John Smith Excel Programming 7 December 3rd 06 02:50 PM
Scrolling columns display [email protected] Excel Programming 0 December 6th 05 11:38 AM
compare two columns and display a third ch90 Excel Discussion (Misc queries) 4 October 13th 05 12:56 PM


All times are GMT +1. The time now is 04:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"