PDA

View Full Version : Solved: how to search cells in a column for a text string



ThePigeon
02-09-2009, 04:53 PM
hey,

I want to make a function that returns a true or false value if one of cells in my excel database contains the same text as another cell. (The database is constantly changing (adding and removing records) so this needs to be factored in).

Let me try and give a vague example:

I want to make it so:


If 'the cell "firstname" contains the same text As any of the used cells In column A

Then
UserForm1.Label1.visble = True

Else
UserForm1.Label1.visble = False


Any help is much appreciated,
Regards,

Joe

Bob Phillips
02-09-2009, 05:09 PM
If Application.Countif(Columns(1),Range("firstname"))>1 Then

UserForm1.Label1.visble = True
Else

UserForm1.Label1.visble = False
End If

ThePigeon
02-10-2009, 05:12 PM
worked a treat apart from one small correction: (change the "1" to a "0")

If Application.Countif(Columns(1),Range("firstname"))>0 Then

UserForm1.Label1.visble = True
Else

UserForm1.Label1.visble = False
End If
as i said very minor...


thanks very much!

regards,

Joe

Bob Phillips
02-11-2009, 01:58 AM
ACtually you can reduce it



UserForm1.Label1.Visible = Application.Countif(Columns(1),Range("firstname").Value) > 0