Coding to check for a sheet name and add it if it's not there
Can someone provide me some code that would check to see if the sheet name "Report" is in the active workbook and if not add it to the end of the sheets, please?
TIA, AlanN |
Coding to check for a sheet name and add it if it's not there
Alan,
Try something like Dim N As Long On Error Resume Next With ThisWorkbook.Worksheets N = Len(.Item("Report").Name) If N = 0 Then .Add(after:=.Item(.Count)).Name = "Report" End If End With -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "AlanN" wrote in message ... Can someone provide me some code that would check to see if the sheet name "Report" is in the active workbook and if not add it to the end of the sheets, please? TIA, AlanN |
Coding to check for a sheet name and add it if it's not there
I tried putting that
Thanks for the macro, Chip. I changed ThisWorkbook to ActiveWorkbook as it is run from my personal.xls file. It works like a charm. AlanN "Chip Pearson" wrote in message ... Alan, Try something like Dim N As Long On Error Resume Next With ThisWorkbook.Worksheets N = Len(.Item("Report").Name) If N = 0 Then .Add(after:=.Item(.Count)).Name = "Report" End If End With -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "AlanN" wrote in message ... Can someone provide me some code that would check to see if the sheet name "Report" is in the active workbook and if not add it to the end of the sheets, please? TIA, AlanN |
All times are GMT +1. The time now is 01:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com