Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Find number - where did I go wrong?

I've got a list of ±4500 employees, each with a unique number. The following
macro almost fit my needs:
Public Sub findEmployee ()
Dim foundCell As Range
Dim Response As Variant
With ActiveSheet
Response = InputBox(prompt:="Employee number ?"
If Response = ""Then Exit Sub
If Not (IsNumeric(Response))Then
MsgBox "You did not key in a NUMBER!"
Exit Sub
Else
Set foundCell=.Range("a4:a5000").Find(what:=Response)
If foundCell Is Nothing Then
MsgBox "The number does not exist"
Else
foundCell.Activate
End if
End if
End With
End Sub
I've tried to include MatchCase:=True, however the number 60 is nt allocated
to an employee, if I key in 60 ' it activates employee 160 which does exits.
Where did I go wrong ???
Please help me.
Thank you
--
HJN
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Find number - where did I go wrong?

Try using LookAt:=xlWhole in the Find call.

Rick


"Hennie Neuhoff" wrote in message
...
I've got a list of ±4500 employees, each with a unique number. The
following
macro almost fit my needs:
Public Sub findEmployee ()
Dim foundCell As Range
Dim Response As Variant
With ActiveSheet
Response = InputBox(prompt:="Employee number ?"
If Response = ""Then Exit Sub
If Not (IsNumeric(Response))Then
MsgBox "You did not key in a NUMBER!"
Exit Sub
Else
Set foundCell=.Range("a4:a5000").Find(what:=Response)
If foundCell Is Nothing Then
MsgBox "The number does not exist"
Else
foundCell.Activate
End if
End if
End With
End Sub
I've tried to include MatchCase:=True, however the number 60 is nt
allocated
to an employee, if I key in 60 ' it activates employee 160 which does
exits.
Where did I go wrong ???
Please help me.
Thank you
--
HJN


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
Find and Replace is going wrong in some cases pol Excel Discussion (Misc queries) 10 May 25th 09 05:35 PM
How to stop Excel from doing wrong Find/Replace Nekodvoru Excel Discussion (Misc queries) 3 August 7th 06 06:59 PM
Wrong Week number Nleric Excel Worksheet Functions 14 May 5th 06 01:26 PM
FIND method doesn't work in UDF. What's wrong with this code? [email protected] Excel Programming 10 July 9th 05 05:32 PM
Can anyone find what is wrong with the following? Derek Richards Excel Programming 3 October 27th 03 11:22 PM


All times are GMT +1. The time now is 01:09 PM.

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"