ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Any ideas why this simple proc. won't work? (https://www.excelbanter.com/excel-programming/300442-any-ideas-why-simple-proc-wont-work.html)

Steph[_3_]

Any ideas why this simple proc. won't work?
 
I get a Compile Error: Invalid Outside Procedure error, and the
debugger highlights the sheet name in the Shtarray "Dom P&L Ship".
I'm obviously screwing up syntax somewhere! Thanks!


Public Shtarray As Sheets
Public sht As Worksheet

Shtarray = Array("Dom P&L Ship", "Cons P&L Ship")

Sub ShowAnnually2003()

For Each sht In Shtarray
Workbook.Sheet(sht).Columns("A:D").EntireColumn.Hi dden = True
Next

End Sub

Bob Phillips[_6_]

Any ideas why this simple proc. won't work?
 
Steph,

Try

Public Shtarray
Public sht As Worksheet

Sub ShowAnnually2003()
Shtarray = Array("Sheet1", "Sheet2")
For Each sht In Worksheets(Shtarray)
sht.Columns("A:D").EntireColumn.Hidden = True
Next sht

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steph" wrote in message
m...
I get a Compile Error: Invalid Outside Procedure error, and the
debugger highlights the sheet name in the Shtarray "Dom P&L Ship".
I'm obviously screwing up syntax somewhere! Thanks!


Public Shtarray As Sheets
Public sht As Worksheet

Shtarray = Array("Dom P&L Ship", "Cons P&L Ship")

Sub ShowAnnually2003()

For Each sht In Shtarray
Workbook.Sheet(sht).Columns("A:D").EntireColumn.Hi dden = True
Next

End Sub





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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com