Hello. I have a system that generates reports and names the worksheets based on a numerical sequence xx-xxx (department number). I would like to add a report title in cell A3 with the department's name based on the worksheet name (department number). The code below works as long as all of the listed sheets are in the workbook. However, if the Worksheet("00-120") is not included the A3 value in Worksheet(00-100) will be "F&A" instead of "General".
Any suggestions on how to modify so that the Range("A3").Value only inserts a value if the Worksheet referenced in the line above it is included in the workbook? This is example lists four department codes but in reality there are approximately 95 worksheets.
Any suggestions on how to modify so that the Range("A3").Value only inserts a value if the Worksheet referenced in the line above it is included in the workbook? This is example lists four department codes but in reality there are approximately 95 worksheets.
Code:
On Error Resume Next
Worksheets("00-100").Activate
Range("A3").Value = "General"
Worksheets("00-120").Activate
Range("A3").Value = "F&A"
Worksheets("00-130").Activate
Range("A3").Value = "BA"
Worksheets("00-140").Activate
Range("A3").Value = "CMO"