Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error with code... ".Visible"

When I run the code below I get the following error:
Run-time error '1004'
Method 'Visible' of object '_Worksheet' failed

This only displays when I have the debug set to break on all errors.

This code is supposed to hide 8 worksheets and leave number 9 visible...the error occurs with Sheet_7
For Each wSheet In ThisWorkbook.Worksheets
If wSheet.CodeName = "Sheet_9" Then
wSheet.Visible = xlSheetVisible
Else
wSheet.Visible = xlSheetVeryHidden
End If
Next wSheet
....any ideas on what's up?

Tim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error with code... ".Visible"

Tim,
just a thought, you cannot hide all of the worksheets in a workbook so if
"sheet_9" is hidden before you enter this loop then you maybe trying to hide
all the other sheets before making Sheet_9 visible.
You might want to change the code to:

Sheet_9.Visible = xlSheetVisible
For Each wSheet In ThisWorkbook.Worksheets
If not wSheet.CodeName = "Sheet_9" Then
wSheet.Visible = xlSheetVeryHidden
End If
Next wSheet

Fred


"Tim" wrote in message
news:ZO2ec.118362$JO3.81283@attbi_s04...
When I run the code below I get the following error:
Run-time error '1004'
Method 'Visible' of object '_Worksheet' failed

This only displays when I have the debug set to break on all errors.

This code is supposed to hide 8 worksheets and leave number 9

visible...the error occurs with Sheet_7
For Each wSheet In ThisWorkbook.Worksheets
If wSheet.CodeName = "Sheet_9" Then
wSheet.Visible = xlSheetVisible
Else
wSheet.Visible = xlSheetVeryHidden
End If
Next wSheet
...any ideas on what's up?

Tim



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Error with code... ".Visible"

Try "Sheet9" instead of "Sheet_9"

Tim wrote:
When I run the code below I get the following error:
Run-time error '1004'
Method 'Visible' of object '_Worksheet' failed

This only displays when I have the debug set to break on all errors.

This code is supposed to hide 8 worksheets and leave number 9
visible...the error occurs with Sheet_7
For Each wSheet In ThisWorkbook.Worksheets
If wSheet.CodeName = "Sheet_9" Then
wSheet.Visible = xlSheetVisible
Else
wSheet.Visible = xlSheetVeryHidden
End If
Next wSheet
...any ideas on what's up?

Tim

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
VBA - error message "Code excecution has been interupted" Jeff Excel Discussion (Misc queries) 1 March 24th 07 02:33 PM
Error Code: "Too many different cell formats" Stephane Rodriguez Excel Discussion (Misc queries) 0 January 13th 07 12:17 PM
"File Format Not Valid" When Starting Excel. Error Code 0D3F6000 EMT_Hawk Excel Discussion (Misc queries) 4 March 31st 06 09:22 PM
Password visible if user selects "view code" kcdonaldson Excel Worksheet Functions 2 December 3rd 05 03:48 PM
error with setting "Items.Visible = True" Stan R Excel Programming 1 August 20th 03 09:51 AM


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