#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
How to Add an Object to the New Object List in windows 2000 Bubu Excel Programming 5 June 3rd 04 12:42 PM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


All times are GMT +1. The time now is 04:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"