ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-time error '1004' - Unable to set the Visible property of the Worksheet class (https://www.excelbanter.com/excel-programming/283531-run-time-error-1004-unable-set-visible-property-worksheet-class.html)

Shalin Chopra

Run-time error '1004' - Unable to set the Visible property of the Worksheet class
 
Excel 97

All of a sudden I am getting the above error on an existing workbook
when activating and deactivating worksheets using VBA e.g.

Private Sub CommandButton3_Click()
Worksheets("WABC").Visible = True
Worksheets("WABC").Select
End Sub

The above procedure has worked previously and I cannot understand why
this is happening.

Any help would be appreciated.

Thanks
Shal

Dave Peterson[_3_]

Run-time error '1004' - Unable to set the Visible property of theWorksheet class
 
Try changing the .takefocusonclick property to False for your commandbutton.

or add
activecell.activate
near the top of your code

This is a bug in xl97 that was fixed in xl2k.



Shalin Chopra wrote:

Excel 97

All of a sudden I am getting the above error on an existing workbook
when activating and deactivating worksheets using VBA e.g.

Private Sub CommandButton3_Click()
Worksheets("WABC").Visible = True
Worksheets("WABC").Select
End Sub

The above procedure has worked previously and I cannot understand why
this is happening.

Any help would be appreciated.

Thanks
Shal


--

Dave Peterson


Paul Robinson

Run-time error '1004' - Unable to set the Visible property of the Worksheet class
 
Hi
Is the workbook (rather than the worksheet) protected? You can't
change the structure of the workbook (like making a sheet visible) if
it is.

regards
Paul
(Shalin Chopra) wrote in message . com...
Excel 97

All of a sudden I am getting the above error on an existing workbook
when activating and deactivating worksheets using VBA e.g.

Private Sub CommandButton3_Click()
Worksheets("WABC").Visible = True
Worksheets("WABC").Select
End Sub

The above procedure has worked previously and I cannot understand why
this is happening.

Any help would be appreciated.

Thanks
Shal


Shalin Chopra

Run-time error '1004' - Unable to set the Visible property of the Worksheet class
 
Thank you all for your help. The workbook had inadvertently been
protected and this was the cause of this error. Works perfectly now.

Cheers
Shal


All times are GMT +1. The time now is 02:12 AM.

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