Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2 Label Options - Forms Object vs Control Box Object | Excel Discussion (Misc queries) | |||
How to Add an Object to the New Object List in windows 2000 | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming |