Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Wildman
 
Posts: n/a
Default VB find (true false)

I'm trying to mix in some VB in a macro I made that
looks for a particular word in a cell. If the word
exist, continue the macro. If it does not end the Macro.
any Ideas?

Cells to search for word a2:a30000
word can be mixed in with other characters.

Thanks in advance
Wildman


  #2   Report Post  
James W.
 
Posts: n/a
Default

Try...
On Error Resume Next
x = Cells.Find(What:= myval, LookAt:=xlPart)
If Err.Number = 91 Then Exit Sub

"Wildman" wrote:

I'm trying to mix in some VB in a macro I made that
looks for a particular word in a cell. If the word
exist, continue the macro. If it does not end the Macro.
any Ideas?

Cells to search for word a2:a30000
word can be mixed in with other characters.

Thanks in advance
Wildman



  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default


For Each cell In Range(A2:A30000")
iPos = Instr(1,cell.Value,"the_word")
If iPos 0 Then
'continue code
End If
Next cell

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Wildman" wrote in message
...
I'm trying to mix in some VB in a macro I made that
looks for a particular word in a cell. If the word
exist, continue the macro. If it does not end the Macro.
any Ideas?

Cells to search for word a2:a30000
word can be mixed in with other characters.

Thanks in advance
Wildman




  #4   Report Post  
Harlan Grove
 
Posts: n/a
Default

Bob Phillips wrote...
For Each cell In Range(A2:A30000")
iPos = Instr(1,cell.Value,"the_word")
If iPos 0 Then
'continue code
End If
Next cell


Alternatively, could use Like.

For Each c In SomeRange
If c.Value Like "*" & your_word_here & "*" Then
'continue
End If
Next c

Sometimes exact text matching (InStr) is more useful, other times
pattern matching (Like) is.

  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

Yep, I agree, that is better

"Harlan Grove" wrote in message
oups.com...
Bob Phillips wrote...
For Each cell In Range(A2:A30000")
iPos = Instr(1,cell.Value,"the_word")
If iPos 0 Then
'continue code
End If
Next cell


Alternatively, could use Like.

For Each c In SomeRange
If c.Value Like "*" & your_word_here & "*" Then
'continue
End If
Next c

Sometimes exact text matching (InStr) is more useful, other times
pattern matching (Like) is.





  #6   Report Post  
Wildman
 
Posts: n/a
Default

so what your saying is....
give my column a range name="test"

and say I'm searching for the word "Wildman"
then in my macro add...

If test.Value like "*"&"wildman"&"*" then
else
exit sub
End If





Thanks again
Wildman

On 5 May 2005 10:40:08 -0700, "Harlan Grove" wrote:

Bob Phillips wrote...
For Each cell In Range(A2:A30000")
iPos = Instr(1,cell.Value,"the_word")
If iPos 0 Then
'continue code
End If
Next cell


Alternatively, could use Like.

For Each c In SomeRange
If c.Value Like "*" & your_word_here & "*" Then
'continue
End If
Next c

Sometimes exact text matching (InStr) is more useful, other times
pattern matching (Like) is.


  #7   Report Post  
Bob Phillips
 
Posts: n/a
Default

even simpler

test.Value like "*wildman*"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Wildman" wrote in message
...
so what your saying is....
give my column a range name="test"

and say I'm searching for the word "Wildman"
then in my macro add...

If test.Value like "*"&"wildman"&"*" then
else
exit sub
End If





Thanks again
Wildman

On 5 May 2005 10:40:08 -0700, "Harlan Grove" wrote:

Bob Phillips wrote...
For Each cell In Range(A2:A30000")
iPos = Instr(1,cell.Value,"the_word")
If iPos 0 Then
'continue code
End If
Next cell


Alternatively, could use Like.

For Each c In SomeRange
If c.Value Like "*" & your_word_here & "*" Then
'continue
End If
Next c

Sometimes exact text matching (InStr) is more useful, other times
pattern matching (Like) is.




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
Grouped Sheets and Formating Pank Mehta Excel Discussion (Misc queries) 3 March 24th 05 01:42 AM
Adding True False Results Arla M Excel Worksheet Functions 6 January 27th 05 06:29 PM
Grand Totals @ Same Place Amber M Excel Worksheet Functions 2 December 30th 04 07:13 PM
Macro to find and delete all FALSE statements Woody13 Excel Discussion (Misc queries) 3 December 8th 04 11:16 PM
Nexsted if across 3 columns Felicity Geronimo Excel Worksheet Functions 4 November 17th 04 11:08 AM


All times are GMT +1. The time now is 07:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"