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 |
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 |
All times are GMT +1. The time now is 04:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com