![]() |
VBA - No Duplicate Sheet
Simple problem with (hopefully) a simple answer
I have a macro that creates a new sheet and names it the contents of strTitle. However, it would be easy for someone to fire off the macro - not realizing there is a sheet of that name already in existance. Thusly, adding a few lines of code to check for the sheet and stop the macro from crashing would be wonderful. However, it's a bit out of my experience and I would appreciate any help. I couldn't find anything that I could get to work from archives. Jordan --- Message posted from http://www.ExcelForum.com/ |
VBA - No Duplicate Sheet
Wedge this code in there somewhere before you rename the sheet.
Dim s Dim bFound As Boolean bFound = False For Each s In Worksheets If LCase(s.Name) = LCase(strTitle) Then bFound = True Next If bFound = True Then MsgBox "You already have a sheet named " & strTitle & ". More inf here..." Exit Sub End If 'Your normal code here -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 08:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com