Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Table of Contents for Excel File

I have a workbook with 72 worksheets in it. There is a combination of
worksheets used for last year (2006) and this year (2007). Last year
I when I created this file I used the code below in the ThisWorkbook
section of the VBA code. When the workbook was opened it would hide
the other worksheets and just show the Table of Contents for 2006.
Now that we are in 2007 I would like it to show both the 2007 and 2006
Table of Contents. Can someone help me modify this script so it will
show the 2007 also.

Thanks

Private Sub Workbook_Open()
Dim c As Worksheet
For Each c In Sheets
If c.Name < "Table Of Contents - 2006" Then
c.Visible = False
Else: c.Visible = True
End If
Next c
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default Table of Contents for Excel File

akafrog18, if your sheet is called Table Of Contents - 2007, try this

Dim c As Worksheet
For Each c In Sheets
If c.Name < "Table Of Contents - 2006" _
And c.Name < "Table Of Contents - 2007" Then
c.Visible = False
Else: c.Visible = True
End If
Next c

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"akafrog18" wrote in message
ups.com...
I have a workbook with 72 worksheets in it. There is a combination of
worksheets used for last year (2006) and this year (2007). Last year
I when I created this file I used the code below in the ThisWorkbook
section of the VBA code. When the workbook was opened it would hide
the other worksheets and just show the Table of Contents for 2006.
Now that we are in 2007 I would like it to show both the 2007 and 2006
Table of Contents. Can someone help me modify this script so it will
show the 2007 also.

Thanks

Private Sub Workbook_Open()
Dim c As Worksheet
For Each c In Sheets
If c.Name < "Table Of Contents - 2006" Then
c.Visible = False
Else: c.Visible = True
End If
Next c
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Table of Contents for Excel File

Thanks Paul. That did work. What does the '_' do that allows it to
work correctly? I had tried using the Or and And several times but
always ended up with a Run Time Error.

Thanks


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default Table of Contents for Excel File

It does nothing as far as making it work, it lets you "split" the line of
code
so instead of having a long line like below. You can see it in the VBA
window and also helps when posting the code to help avoid "word wrap".

If c.Name < "Table Of Contents - 2006" And c.Name < "Table Of Contents -
2007" Then
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"akafrog18" wrote in message
oups.com...
Thanks Paul. That did work. What does the '_' do that allows it to
work correctly? I had tried using the Or and And several times but
always ended up with a Run Time Error.

Thanks




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Table of Contents for Excel File

What does the '_' do

The "_" doesn't do anything in terms of changing the functionality of the
code. It simply allows you to write a single logical line of code across two
or more physical lines of code. For example,

Range( _
"A1" _
) _
..Value _
= _
123

is interpreted by VBA as if it were written on a single line:

Range("A1").Value = 123

Note that there must be a space before the underscore character.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"akafrog18" wrote in message
oups.com...
Thanks Paul. That did work. What does the '_' do that allows it to
work correctly? I had tried using the Or and And several times but
always ended up with a Run Time Error.

Thanks




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
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 03:56 AM
Links picking up values from an older version of linked file Cate Links and Linking in Excel 4 October 20th 05 01:53 PM
How do I view Pivot Table source data file and field names? chocolate2346 Excel Discussion (Misc queries) 4 September 14th 05 06:57 PM
Question from MOS file E03C-1-1 , Creating data and contents Dora Excel Discussion (Misc queries) 1 June 5th 05 08:51 AM
save excel file from a table delimited file (.txt) using macros sedamfo New Users to Excel 1 February 15th 05 04:19 AM


All times are GMT +1. The time now is 07:03 PM.

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"