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

Hi. I wrote what I thought was going to be simple code. I added
check boxes to my workbook using the control toolbox. The following
code is called by one checkbox. All I am trying to do is hide columns
A:D on 4 spreadsheets. When I run this I get the error Compile Error:
Invalid Outside Procedure.

Public SheetArray As Sheets

set shtarray = Sheets((DomShip, ConShip, IntShip, FinShip)) 'these
sheets are named in the properties window

Sub HideQtly2003()

Application.ScreenUpdating = False
shtarray.Columns("A:D").EntireColumn.Hidden = True
Application.ScreenUpdating = True

End Sub


Any ideas? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Code to hide columns problem

I don't understand what this line is trying to do ..

set shtarray = Sheets((DomShip, ConShip, IntShip, FinShip))

Well, actually, I do, but it is not a valid syntax. The closest I can think of is ..

shtarray = Array("DomShip", "ConShip", "IntShip", "FinShip")

This will create an array - of the NAMES of the sheets

Then in your HideQtly2003 subroutine you can access them with something like ..

for each name in shtarra
workbook.Sheet(name)..Columns("A:D").EntireColumn. Hidden = Tru
nex

This is 'air code', but I'm sure it's cloaser to what you need than your formulation

BTW, the missing external routine is almost certainly Sheets() in that first line of code

Tom Laveda


----- Steph wrote: ----

Hi. I wrote what I thought was going to be simple code. I adde
check boxes to my workbook using the control toolbox. The followin
code is called by one checkbox. All I am trying to do is hide column
A:D on 4 spreadsheets. When I run this I get the error Compile Error
Invalid Outside Procedure

Public SheetArray As Sheet

set shtarray = Sheets((DomShip, ConShip, IntShip, FinShip)) 'thes
sheets are named in the properties windo

Sub HideQtly2003(

Application.ScreenUpdating = Fals
shtarray.Columns("A:D").EntireColumn.Hidden = Tru
Application.ScreenUpdating = Tru

End Su


Any ideas? Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Code to hide columns problem

Hi,
not very elegent but should do the job, stick it all in the click
event of the check box

x = ActiveSheet.Name

If CheckBox1.Value = True Then

Sheets("DomShip").Activate
Sheets("DomShip").Range("A:D").Select
Selection.EntireColumn.Hidden = True
Sheets("ConShip").Activate
Sheets("ConShip").Range("A:D").Select
Selection.EntireColumn.Hidden = True
Sheets("IntShip").Activate
Sheets("IntShip").Range("A:D").Select
Selection.EntireColumn.Hidden = True
Sheets("FinShip").Activate
Sheets("FinShip").Range("A:D").Select
Selection.EntireColumn.Hidden = True


Else

Sheets("DomShip").Activate
Sheets("DomShip").Range("A:D").Select
Selection.EntireColumn.Hidden = False
Sheets("ConShip").Activate
Sheets("ConShip").Range("A:D").Select
Selection.EntireColumn.Hidden = False
Sheets("IntShip").Activate
Sheets("IntShip").Range("A:D").Select
Selection.EntireColumn.Hidden = False
Sheets("FinShip").Activate
Sheets("FinShip").Range("A:D").Select
Selection.EntireColumn.Hidden = False

End If

Sheets(x).Activate
Sheets(x).Range("F1").Select


good luck
ross
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
vb code to hide columns pm tlb Excel Discussion (Misc queries) 4 May 28th 09 09:36 AM
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
Hide columns code jlclyde Excel Discussion (Misc queries) 0 April 25th 08 03:17 PM
hide code does not hide Wanna Learn Excel Discussion (Misc queries) 2 March 6th 08 07:21 PM
Hide Columns before Print problem Stuart[_5_] Excel Programming 0 August 1st 03 08:00 PM


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