VBA referencing a non-existent sheet

Brass Contributor

The VBA code in my Safety Inspection worksheet is referencing a worksheet named "Training". But that sheet doesn't exist in the workbook. I have already made sure that there are no hidden pages. I know that this code is referencing this workbook since the code includes "ActiveWorkbook"

 

Does anyone have any suggestions on how to fix this or why it might be happening?

 

Screenshot 2023-04-02 094314.pngScreenshot 2023-04-02 094330.png

4 Replies

@LilYawney 

Does the copy_name macro get called elsewhere in the code? If not, you can delete or comment out this macro.

@LilYawney  You say "there are no hidden pages" but how did you check?  There is a property/option for "VeryHidden" meaning on the workbook if you right click on the sheet tabs to 'unhide' it isn't there.

Since you are in VBA, did you check the project explorer (ctrl-R if it isn't open) as shown on the left in this image?  Or Type in the Immediate window (ctrl-g) as shown in the image to check for the status (i.e. a 2 = VeryHidden

mtarler_0-1680459255897.png

 

I did do the right click on the sheet tabs to unhide all sheets; however, there weren't any extra sheets in the project explorer. I did try to check the status in the immediate window but I keep getting a popup message saying "runtime error 9: subscript out of range"

@LilYawney 

The workbook that you attached to your other recent discussion does not contain a worksheet Training, indeed. I'd remove the entire Module1 - the code in this module is not called in any other module.