Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro: Finding Text Within Text
I need to determine whether a cell contains a particular string of text, what
is the best function or way of doing this in my macro? For Example: I want to know whether cell A1 contains the text "AUA", if it does then I'm going to execute some code, if it doesn't then I'm going to execute some other code. I was trying to use the Range.Find method but I had a lot of trouble with it. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro: Finding Text Within Text
maybe something simple like this:
Sub test() Dim ws As Worksheet Set ws = Worksheets("Sheet1") With ws If InStr(.Range("A1"), "AUA") Then MsgBox "found" End If End With End Sub -- Gary "Simon" wrote in message ... I need to determine whether a cell contains a particular string of text, what is the best function or way of doing this in my macro? For Example: I want to know whether cell A1 contains the text "AUA", if it does then I'm going to execute some code, if it doesn't then I'm going to execute some other code. I was trying to use the Range.Find method but I had a lot of trouble with it. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro: Finding Text Within Text
Hi
You don't say if you want a case sensitive function, so I have made it case sensitive by setting MatchCase=True. Here's a way to do it: Set f = Range("A1").Find(what:="AUA", MatchCase:=True) If f Is Nothing Then MsgBox "Not found" Else MsgBox "Found" End If Regards, Per "Simon" skrev i meddelelsen ... I need to determine whether a cell contains a particular string of text, what is the best function or way of doing this in my macro? For Example: I want to know whether cell A1 contains the text "AUA", if it does then I'm going to execute some code, if it doesn't then I'm going to execute some other code. I was trying to use the Range.Find method but I had a lot of trouble with it. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Finding text or part of a text inside the value cell | Excel Programming | |||
Finding text in a cell and returning a value based on that text | Excel Discussion (Misc queries) | |||
Finding Specific Text in a Text String | Excel Worksheet Functions | |||
Find WorksheetFunction - finding text within text | Excel Programming | |||
Macro query - finding mutliple occurences of text in a column | Excel Programming |