Run Time Error 1004 Method Worksheet of object '_Global Failed

Marlton_07

New Member
Joined
Jul 8, 2012
Messages
1
Please help.
I found this error in below codes.
'Created by Marlton A. Soliven
Option Explicit
Option Compare Text
'Password to unhide sheets
Const pWord = "*****"
Sub HideSheets()
'Set worksheet to Very Hidden so that it can only be unhidden by a macro
Worksheets("Accounting").Visible = xlSheetVisible (Error found here!)
End Sub
Sub ShowSheets()
'Prompt the user for a password and unhide the worksheet if correct
Select Case InputBox("Please enter the password to unhide the sheet", _
"Enter Password")

Case Is = pWord
With Worksheets("Accounting")
.Visible = xlSheetVisible
.Activate
.Range("A1").Select
End With
Case Else
MsgBox "Sorry, that password is incorrect!", _
vbCritical + vbOKOnly, "You are not authorized!"
End Select
End Sub
Option Explicit
Private Sub Workbook_Open()
'Turn off screen updates
Application.ScreenUpdating = False
'Hide confidential sheet at startup
Call HideSheets

'Activate cell A1 on the Dashboard sheet at startup
With Worksheets("Dashboard")
.Activate
.Range("A1").Select
End With
'Restore screen updates
Application.ScreenUpdating = True
End Sub

Appreciate anyone who can assist me.
Thank so much.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi and welcome to the Board
the higlighted line works fine for me
Code:
Sub HideSheets()
Worksheets("Accounting").Visible = xlSheetVisible
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,421
Messages
6,119,392
Members
448,891
Latest member
tpierce

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top