Excel VBA Find

rabso

New Member
Joined
Oct 21, 2010
Messages
36
Good morning
I have a userform that shows the current user logged in, That get displayed on a userform (the field is called "txt_user"). On that userfrom we have a button that validates the userid to see if its admin in that document.
In a tab called data we have a list of admin users. Now if that userid is in that list I need it to pass validation. Here is my code. It doesnt seem to want to work though, any ideas? Thank you Richard Baker.

Code:
If Sheets("Data").Range("A1:A10").Find(txt_user.Value, LookIn:=xlValues) = True Then
MsgBox ("admin")
Else
MsgBox ("no admin")
End If
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hi. Try

Code:
Set Found = Sheets("Data").Range("A1:A10").Find(txt_user.Value, LookIn:=xlValues)
If Not Found Is Nothing Then
 

Watch MrExcel Video

Forum statistics

Threads
1,108,960
Messages
5,525,911
Members
409,671
Latest member
nasseralateek

This Week's Hot Topics

Top