#1   Report Post  
Posted to microsoft.public.excel.misc
teeb
 
Posts: n/a
Default MatchCase syntax?


I am trying to add names to a list which may contain names already. The
user enters the name in a box and then presses enter. I only want to
add a name to the list if it doesn't exists in the list already. This
is almost working, although the code seems to be picking up parts of
names already in the list. i.e. if I wanted to add the name "Ann" to
the list, but the list already contains the name "Annabel" then it says
the name already exists. Can anyone help me so that it only says the
name exists in the list if it is an exact match...the code i have sol
far is below...........Thanks

Sub input_staff_name_checks()

staff_name = UCase(Cells(15, 9).Value)

If Len(staff_name) 0 Then

Set rngLook = Worksheets("Project Codes & Staff
Names").Range("F5:F100")

For j = 5 To 500

If staff_name < Cells(j, 6).Value Then

Set rngFind = rngLook.Find(staff_name,
MatchCase:=True)

If rngFind Is Nothing Then
Call input_names *** this method here enters the
name in the list once the check has been done ***
Else
MsgBox ("Staff member's name is already on the
list!")
End If

Set ringFind = Nothing
Exit For

End If

Next j

Else
MsgBox ("Please enter a staff member's name")

End If

End Sub


--
teeb
------------------------------------------------------------------------
teeb's Profile: http://www.excelforum.com/member.php...o&userid=13172
View this thread: http://www.excelforum.com/showthread...hreadid=539206

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default MatchCase syntax?

Add LookAt:=xlWhole to the Find statement.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"teeb" wrote in message
...

I am trying to add names to a list which may contain names already. The
user enters the name in a box and then presses enter. I only want to
add a name to the list if it doesn't exists in the list already. This
is almost working, although the code seems to be picking up parts of
names already in the list. i.e. if I wanted to add the name "Ann" to
the list, but the list already contains the name "Annabel" then it says
the name already exists. Can anyone help me so that it only says the
name exists in the list if it is an exact match...the code i have sol
far is below...........Thanks

Sub input_staff_name_checks()

staff_name = UCase(Cells(15, 9).Value)

If Len(staff_name) 0 Then

Set rngLook = Worksheets("Project Codes & Staff
Names").Range("F5:F100")

For j = 5 To 500

If staff_name < Cells(j, 6).Value Then

Set rngFind = rngLook.Find(staff_name,
MatchCase:=True)

If rngFind Is Nothing Then
Call input_names *** this method here enters the
name in the list once the check has been done ***
Else
MsgBox ("Staff member's name is already on the
list!")
End If

Set ringFind = Nothing
Exit For

End If

Next j

Else
MsgBox ("Please enter a staff member's name")

End If

End Sub


--
teeb
------------------------------------------------------------------------
teeb's Profile:

http://www.excelforum.com/member.php...o&userid=13172
View this thread: http://www.excelforum.com/showthread...hreadid=539206



  #3   Report Post  
Posted to microsoft.public.excel.misc
Stefi
 
Posts: n/a
Default MatchCase syntax?

Try this:

Set rngFind = rngLook.Find(staff_name, LookAt:=xlWhole,
MatchCase:=True)

Regards,
Stefi

€˛teeb€¯ ezt Ć*rta:


I am trying to add names to a list which may contain names already. The
user enters the name in a box and then presses enter. I only want to
add a name to the list if it doesn't exists in the list already. This
is almost working, although the code seems to be picking up parts of
names already in the list. i.e. if I wanted to add the name "Ann" to
the list, but the list already contains the name "Annabel" then it says
the name already exists. Can anyone help me so that it only says the
name exists in the list if it is an exact match...the code i have sol
far is below...........Thanks

Sub input_staff_name_checks()

staff_name = UCase(Cells(15, 9).Value)

If Len(staff_name) 0 Then

Set rngLook = Worksheets("Project Codes & Staff
Names").Range("F5:F100")

For j = 5 To 500

If staff_name < Cells(j, 6).Value Then

Set rngFind = rngLook.Find(staff_name,
MatchCase:=True)

If rngFind Is Nothing Then
Call input_names *** this method here enters the
name in the list once the check has been done ***
Else
MsgBox ("Staff member's name is already on the
list!")
End If

Set ringFind = Nothing
Exit For

End If

Next j

Else
MsgBox ("Please enter a staff member's name")

End If

End Sub


--
teeb
------------------------------------------------------------------------
teeb's Profile: http://www.excelforum.com/member.php...o&userid=13172
View this thread: http://www.excelforum.com/showthread...hreadid=539206


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
Syntax for using "IF"... garry05 Excel Worksheet Functions 1 December 7th 05 03:44 PM
Insert more than 1 Row Syntax blazzae Excel Worksheet Functions 5 July 10th 05 12:46 AM
Rate syntax KWIGZ Excel Discussion (Misc queries) 2 June 16th 05 07:59 PM
Vlookup Syntax Error YV New Users to Excel 9 December 23rd 04 05:28 PM
Previous Post - Correct Syntax Query Clarence Crow Excel Worksheet Functions 0 December 7th 04 05:35 AM


All times are GMT +1. The time now is 03:13 PM.

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

About Us

"It's about Microsoft Excel"