![]() |
Name Verification
I have a userform that creates a new worksheet, enters data from the form,
and performs calculations based on that data. One of the entries on the form is an ID which becomes the name of the new worksheet. How can I check the names of all the worksheets (indefinite number of sheets) to verify the new ID isn't a duplicate and stop the program from running? The desired result is to prompt the user for a new name and then run the procedure. I tried an If...Then...Else statement, but it's renaming and overwriting the original and still creating a new blank sheet. I hope I haven't confused you! Thanks! |
Name Verification
assume id is in myVar
On Error Resume Next Set sh = worksheets(myVar) On Error Goto 0 If sh Is Nothing Then Worksheets.Add.name = myVar End If -- HTH Bob Phillips "MAWII" wrote in message ... I have a userform that creates a new worksheet, enters data from the form, and performs calculations based on that data. One of the entries on the form is an ID which becomes the name of the new worksheet. How can I check the names of all the worksheets (indefinite number of sheets) to verify the new ID isn't a duplicate and stop the program from running? The desired result is to prompt the user for a new name and then run the procedure. I tried an If...Then...Else statement, but it's renaming and overwriting the original and still creating a new blank sheet. I hope I haven't confused you! Thanks! |
All times are GMT +1. The time now is 12:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com