Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Issue with Hiding Sheets Depending on Workbook Name

I am having some syntax issue trying to modify this script now. I am
missing something completly obvious can one of you help. (The reasoning

behind this is that when closing the workbook it will save itself twice

each time it saves different sheets will be hidden so that when people
open each workbook only the information they need will be shown.) Here
is my code.

Sub hidebut()
For Each ws In Worksheets
If Active.Workbook = "abefrof.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = True
Next ws


If Active.Workbook = "abetest1.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = False
Next ws


End Sub


Thanks for all the help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Issue with Hiding Sheets Depending on Workbook Name

Sub hidebut()
Const sWSVisible = "Solution Direct Tracking"

For Each ws In Workbooks("abefrof.xls").Worksheets
If ws.Name < sWSVisible Then ws.Visible = True
Next ws

For Each ws In Workbooks("abetest1.xls").Worksheets
If ws.Name < sWSVisible Then ws.Visible = True
Next ws
End Sub

HTH
--
AP

"Kris" a écrit dans le message de news:
...
I am having some syntax issue trying to modify this script now. I am
missing something completly obvious can one of you help. (The reasoning

behind this is that when closing the workbook it will save itself twice

each time it saves different sheets will be hidden so that when people
open each workbook only the information they need will be shown.) Here
is my code.

Sub hidebut()
For Each ws In Worksheets
If Active.Workbook = "abefrof.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = True
Next ws


If Active.Workbook = "abetest1.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = False
Next ws


End Sub


Thanks for all the help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Issue with Hiding Sheets Depending on Workbook Name

Thanks for the help. I must be doing something wrong. When I run this
script it gives me an error and highlights this line:

For Each ws In Workbooks("abefrof.xls").Worksheets

I think it is because I don't have this workbook open. What I am trying
to do is run the macro one way if the name is one thing and a different
way if the workbook name is another. Only one is open at a time. Can
you help me figure out what I did wrong?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Issue with Hiding Sheets Depending on Workbook Name

Here is your original code, with syntax errors corrected

'---------------
Sub hidebut()
Dim ws As Worksheet

For Each ws In Worksheets
If ActiveWorkbook.Name = "abefrof.xls" Then
If ws.Name < "Solution Direct Tracking" Then
ws.Visible = True
End If
End If

If ActiveWorkbook.Name = "abetest1.xls" Then
If ws.Name < "Solution Direct Tracking" Then
ws.Visible = False
End If
End If
Next ws


End Sub
'--------------
"Kris" a écrit dans le message de news:
...
I am having some syntax issue trying to modify this script now. I am
missing something completly obvious can one of you help. (The reasoning

behind this is that when closing the workbook it will save itself twice

each time it saves different sheets will be hidden so that when people
open each workbook only the information they need will be shown.) Here
is my code.

Sub hidebut()
For Each ws In Worksheets
If Active.Workbook = "abefrof.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = True
Next ws


If Active.Workbook = "abetest1.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = False
Next ws


End Sub


Thanks for all the help



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
Hiding Sheets in workbook - help burritoj Excel Discussion (Misc queries) 4 October 1st 08 12:13 AM
hiding rows depending on the date Jan Buckley Excel Discussion (Misc queries) 4 December 22nd 06 11:13 AM
Hiding named ranges depending on a cell value Ctech[_109_] Excel Programming 3 March 20th 06 11:07 AM
Hiding sheets within a workbook Brian Charts and Charting in Excel 1 December 15th 05 07:14 PM
hiding a control depending on a cell's value yoram Excel Programming 13 November 16th 05 10:02 PM


All times are GMT +1. The time now is 05:04 PM.

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

About Us

"It's about Microsoft Excel"