Forum Discussion
LilYawney
Apr 02, 2023Brass Contributor
VBA referencing a non-existent sheet
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?
4 Replies
Sort By
- mtarlerSilver Contributor
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
- LilYawneyBrass ContributorI 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"
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.
Does the copy_name macro get called elsewhere in the code? If not, you can delete or comment out this macro.