Method Sheets("ShtName").Visble Returning an Error in Excel 2016 not 2010

RichardElk

New Member
Joined
Feb 7, 2014
Messages
8
Hi All,

I have recently upgraded to Excel 2016 from Excel 2010; I had a pretty simple macro in an existing sheet which changes the state of various worksheets from xlveryhidden to xlvisible

When I run the macro in Excel 2016 i get the following error message:

run-time error '-2147417848(80010108)':
Method 'Visible' of object '_Worksheet' failed

When the same code is run in Excel 2010 there is no issue. On a debug in 2016 the offending code is: (the bolded text is where the debug starts)

Sheets("General Overview").Visible = True
Sheets("Center Hi & Low").Visible = True
Sheets("Chart - Directs").Visible = True
Sheets("GENERAL Variance Reports").Visible = True
Sheets("Project Dashboard").Visible = True

None of the sheets are protected and there is a "Navigation & Initialization" sheet which is always visible.

I have also tried changing the code from Sheets("Name").visible to sheet#.visible which results in Excel shutting down.
I have also tried using xlvisible / xlveryhidden rather than simply using True.

Simply using excel 2010 is not an option for me as some of my intended users only have 2016.

Any help would be greatly appreciated.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
If it's possible, could you upload your file to some cloud storage to investigate the issue?
 
Upvote 0
If it's possible, could you upload your file to some cloud storage to investigate the issue?

Unfortunately i can not post the file as there is confidential information contained within it. I attempted to re-create the issue in a "sample" version and it did not occur.

Upon further investigation though, when i add a break to the bolded line the code executes without error when i step through the break. When I remove the line:

Sheets("Chart - Directs").Visible = True

the code also executes without error.

Not sure if that helps; please let me know if i can provide further information.
 
Upvote 0
All I can say is that Excel 2016 has some problems with VBA. Three days ago MrExcel MVP Domenic had the same behavior with his code. While stepping thru F8, the code executed fine, but when he run it (F5), VBA raised error. You have the same behavior. I advise you to call to MS Support. :)
 
Upvote 0
Not at all
hi.gif
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,635
Members
452,661
Latest member
Nonhle

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