ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find text in string (https://www.excelbanter.com/excel-programming/317754-find-text-string.html)

Mike D.[_3_]

Find text in string
 
Hi. Within a loop, I would like for the macro to find the text "On Hand"
within a cell on a given row. If the text exists anywhere in the cell, I
would like to delete the row.

What command should I use? I know that if I wanted to find this in the left
or right of the string I would use the LEFT or RIGHT function, but I don't
know how to have it search anywhere in the string. Thanks!

Don Guillett[_4_]

Find text in string
 
Have a look at

InStr

Sub findwords()
x = InStr(ActiveCell, "on hand")
MsgBox x
End Sub
--
Don Guillett
SalesAid Software

"Mike D." <Mike wrote in message
...
Hi. Within a loop, I would like for the macro to find the text "On Hand"
within a cell on a given row. If the text exists anywhere in the cell, I
would like to delete the row.

What command should I use? I know that if I wanted to find this in the

left
or right of the string I would use the LEFT or RIGHT function, but I don't
know how to have it search anywhere in the string. Thanks!




KL[_5_]

Find text in string
 
Sub Macro1()
If InStr(ActiveCell, "on hand") Then ActiveCell.EntireRow.Delete
End Sub

Regards,
KL

"Mike D." <Mike wrote in message
...
Hi. Within a loop, I would like for the macro to find the text "On Hand"
within a cell on a given row. If the text exists anywhere in the cell, I
would like to delete the row.

What command should I use? I know that if I wanted to find this in the
left
or right of the string I would use the LEFT or RIGHT function, but I don't
know how to have it search anywhere in the string. Thanks!




Harald Staff

Find text in string
 
Hi

Instr, like

S = "neon hand sign"
If InStr(S, "on hand") 0 Then MsgBox "Found it"

HTH. best wishes Harald

"Mike D." <Mike skrev i melding
...
Hi. Within a loop, I would like for the macro to find the text "On Hand"
within a cell on a given row. If the text exists anywhere in the cell, I
would like to delete the row.

What command should I use? I know that if I wanted to find this in the

left
or right of the string I would use the LEFT or RIGHT function, but I don't
know how to have it search anywhere in the string. Thanks!




Mike D.

Find text in string
 
Thanks, Folks! The INSTR works well.

Mike.

"Mike D." wrote:

Hi. Within a loop, I would like for the macro to find the text "On Hand"
within a cell on a given row. If the text exists anywhere in the cell, I
would like to delete the row.

What command should I use? I know that if I wanted to find this in the left
or right of the string I would use the LEFT or RIGHT function, but I don't
know how to have it search anywhere in the string. Thanks!


Don Guillett[_4_]

Find text in string
 
glad to help

--
Don Guillett
SalesAid Software

"Mike D." wrote in message
...
Thanks, Folks! The INSTR works well.

Mike.

"Mike D." wrote:

Hi. Within a loop, I would like for the macro to find the text "On

Hand"
within a cell on a given row. If the text exists anywhere in the cell,

I
would like to delete the row.

What command should I use? I know that if I wanted to find this in the

left
or right of the string I would use the LEFT or RIGHT function, but I

don't
know how to have it search anywhere in the string. Thanks!





All times are GMT +1. The time now is 08:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com