PC Review


Reply
Thread Tools Rate Thread

display columns

 
 
mwam423
Guest
Posts: n/a
 
      28th Jul 2008
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.
 
Reply With Quote
 
 
 
 
Wigi
Guest
Posts: n/a
 
      28th Jul 2008
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.

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      28th Jul 2008
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" <(E-Mail Removed)> wrote in message
news:2924F5CD-AE99-4020-A230-(E-Mail Removed)...
> 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.


 
Reply With Quote
 
mwam423
Guest
Posts: n/a
 
      29th Jul 2008
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: display only columns A to I John Smith Microsoft Excel Programming 0 3rd Dec 2006 02:50 PM
Re: display only columns A to I John Smith Microsoft Excel Programming 0 3rd Dec 2006 02:25 PM
Re: display only columns A to I =?Big5?B?pNGmYaywxGw=?= Microsoft Excel Programming 0 2nd Dec 2006 11:25 PM
display more columns =?Utf-8?B?ZGF2aWQ=?= Microsoft Excel Misc 2 10th Nov 2004 05:34 AM
many columns can't display. harrycatcjf Microsoft Excel Misc 2 23rd Apr 2004 01:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:23 PM.