Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Hiding columns in a named range

Is there a way of hiding columns in named ranges in VBA? I've got a load of
columns that I want to show and hide, but I might want to add other columns
in the worksheets later, so named ranges would make life easier.

I would have thought it was simple, but I just get an error that I'm "unable
to set hidden property of range class"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Hiding columns in a named range

Hi
Either of these will hide column 2 in range "tester"

ActiveSheet.Range("tester").Columns(2).Hidden = True

or
ActiveSheet.Range("tester").Cells(1,2).EntireColum n.Hidden = True

There is no Hide method, so this won't work

ActiveSheet.Range("tester").Columns(2).Hide

no matter how tempting it looks!
regards
Paul

On Apr 28, 12:21*pm, malcomio
wrote:
Is there a way of hiding columns in named ranges in VBA? I've got a load of
columns that I want to show and hide, but I might want to add other columns
in the worksheets later, so named ranges would make life easier.

I would have thought it was simple, but I just get an error that I'm "unable
to set hidden property of range class"


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Hiding columns in a named range


Forgot to mention
You may also find this useful

With ActiveSheet.Range("tester")
.Range(.Columns(2), .Columns(4)).Hidden = True
End With

which will hide columns 2 to 4.
regards
Paul

On Apr 28, 12:32*pm, wrote:
Hi
Either of these will hide column 2 in range "tester"

ActiveSheet.Range("tester").Columns(2).Hidden = True

or
ActiveSheet.Range("tester").Cells(1,2).EntireColum n.Hidden = True

There is no Hide method, so this won't work

ActiveSheet.Range("tester").Columns(2).Hide

no matter how tempting it looks!
regards
Paul

On Apr 28, 12:21*pm, malcomio
wrote:



Is there a way of hiding columns in named ranges in VBA? I've got a load of
columns that I want to show and hide, but I might want to add other columns
in the worksheets later, so named ranges would make life easier.


I would have thought it was simple, but I just get an error that I'm "unable
to set hidden property of range class"- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Hiding columns in a named range

thanks Paul
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Hiding columns in a named range

do you know if pivot tables on a worksheet cause problems? maybe i'm having
problems with worksheet and workbook scope, but I have a range of columns K:V
called "wholeyear", scoped to each worksheet, and when I run the procedure it
hides columns U:AF.

Very strange, especially as this isn't a named range at all.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Hiding columns in a named range

Hi
Are you hiding columns relative to some range

e.g. Range("B1:C1").Columns("B:B").Hidden = true

will hide the second column in "B1:C1" i.e. column C of the worksheet.
regards
Paul

On Apr 28, 2:25*pm, malcomio
wrote:
do you know if pivot tables on a worksheet cause problems? maybe i'm having
problems with worksheet and workbook scope, but I have a range of columns K:V
called "wholeyear", scoped to each worksheet, and when I run the procedure it
hides columns U:AF.

Very strange, especially as this isn't a named range at all.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Hiding columns in a named range

I am hiding columns within a range, and those columns are the values section
of a pivot table.

It seems to be affecting a different range, depending on the number of
columns in the pivot table, even though the named range is set to the values
section. It's very strange. Would you mind if I emailed you an example of the
problem?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Hiding columns in a named range

Sure - probably tomorrow when I reply, but I'll reply direct to you.
Paul

On Apr 28, 4:06*pm, malcomio
wrote:
I am hiding columns within a range, and those columns are the values section
of a pivot table.

It seems to be affecting a different range, depending on the number of
columns in the pivot table, even though the named range is set to the values
section. It's very strange. Would you mind if I emailed you an example of the
problem?


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Hiding columns in a named range

try this
Sub hidecolinrng()
'Range("hiderng").Cells(1, 3).EntireColumn.Hidden = False
Range("hiderng").Range(Cells(1, 3), Cells(1, 4)).EntireColumn.Hidden = True
'FALSE
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"malcomio" wrote in message
...
Is there a way of hiding columns in named ranges in VBA? I've got a load
of
columns that I want to show and hide, but I might want to add other
columns
in the worksheets later, so named ranges would make life easier.

I would have thought it was simple, but I just get an error that I'm
"unable
to set hidden property of range class"


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
unhide columns in named range blonde1030 Excel Programming 1 June 26th 07 10:27 PM
Hiding rows that are included in a named range Barb Reinhardt Excel Programming 1 November 1st 06 04:47 PM
How can I hide a range of columns without hiding charts there? dbsavoy Charts and Charting in Excel 2 August 31st 06 04:30 PM
Named Range - Empty columns Tempy Excel Programming 8 July 8th 04 03:56 PM
Hiding Blank lines in named range Carl Brehm Excel Programming 3 August 8th 03 05:17 PM


All times are GMT +1. The time now is 06:18 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"