running a sub when found

S

solo_razor

hello,

I have an interresting problem. i'm writing a sub that must execute
another sub when the criteria has been met. E.G.
IF worksheetS("test").cells.find("testing") = true then (execute anther
subroutine)

I can't get anything to work.

Regards,

Niek
 
C

Chip Pearson

Niek,

If I understand your problem correctly, try something like

Dim FoundCell As Range
Set FoundCell = Worksheets("Test").Cells.Find("testing")
If Not FoundCell Is Nothing Then
' string found
DoSomething
Else
' string not found
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
D

Don Guillett

Not the best way but it seems to work.

Sub iffound()
On Error Resume Next
If Worksheets("Sheet5").Cells.Find("ff") = "ff" Then MsgBox "Hi"
End Sub

but this also works
Sub iffound()
On Error Resume Next
If Worksheets("Sheet5").Cells.Find("fff") = "ff" Then MsgBox "Hi"
End Sub

and this doesn't
Sub iffound()
On Error Resume Next
If Worksheets("Sheet5").Cells.Find("ff") = "fff" Then MsgBox "Hi"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top