![]() |
Object Name
The workbook starts with one sheet and using other code, I prompt use to inser a new one. At that time the user input, which is the employe number, is entered in a cell and the sheet name is changed to the em code also. when users enter emp codes, I need to validate if there already a shee with the same emp code. Then I can pop up a msg telling the user tha that emp code already exists -- halem ----------------------------------------------------------------------- halem2's Profile: http://www.excelforum.com/member.php...nfo&userid=993 View this thread: http://www.excelforum.com/showthread.php?threadid=26288 |
Object Name
I only see your side of the thread, so I don't know if
anyone has suggested this, but here is some code you can try: 'Assuming the emp number is in the variable EmpNumber For Each ws In ThisWorkbook.Worksheets If ws.Name = EmpNumber Then MsgBox "The sheet named " & EmpNumber & " already exists.", vbOKOnly + vbInformation, "Sheet Exists" Exit Sub Else Sheets.Add ActiveSheet.Name = EmpNumber End If Next ws tod -----Original Message----- The workbook starts with one sheet and using other code, I prompt user to inser a new one. At that time the user input, which is the employee number, is entered in a cell and the sheet name is changed to the emp code also. when users enter emp codes, I need to validate if there already a sheet with the same emp code. Then I can pop up a msg telling the user that that emp code already exists. -- halem2 --------------------------------------------------------- --------------- halem2's Profile: http://www.excelforum.com/member.php? action=getinfo&userid=9930 View this thread: http://www.excelforum.com/showthread...hreadid=262888 . |
Object Name
Wouldn't this only work if there was no conflict or the conflicting name was
the first worksheet in the tab order? -- Regards, Tom Ogilvy "Tod" wrote in message ... I only see your side of the thread, so I don't know if anyone has suggested this, but here is some code you can try: 'Assuming the emp number is in the variable EmpNumber For Each ws In ThisWorkbook.Worksheets If ws.Name = EmpNumber Then MsgBox "The sheet named " & EmpNumber & " already exists.", vbOKOnly + vbInformation, "Sheet Exists" Exit Sub Else Sheets.Add ActiveSheet.Name = EmpNumber End If Next ws tod -----Original Message----- The workbook starts with one sheet and using other code, I prompt user to inser a new one. At that time the user input, which is the employee number, is entered in a cell and the sheet name is changed to the emp code also. when users enter emp codes, I need to validate if there already a sheet with the same emp code. Then I can pop up a msg telling the user that that emp code already exists. -- halem2 --------------------------------------------------------- --------------- halem2's Profile: http://www.excelforum.com/member.php? action=getinfo&userid=9930 View this thread: http://www.excelforum.com/showthread...hreadid=262888 . |
All times are GMT +1. The time now is 01:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com