Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Search for text string

Hi! I have a macro that searches through a list of data using objects. I want
to see if a cell contains a certain value and if so then do something. The
cell can contain eg: AUSTRIA GVB 2012 JUL 5.0%. However, I am just interested
in AUSTRIA. The rest does not matter. I have a list of the words I am looking
for. Basically all I want to know is how can I search a cell for a certain
value? Thanks alot!!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Search for text string

Hello Arne
Dim Rg As Range
With Range("A1:E1")
Set Rg = .Find("AUSTRIA", LookIn:=xlValues, lookat:=xlPart)
If Not Rg Is Nothing Then
MsgBox "Value found in " & Rg.Address
End If
End With

See VBA help for further info on Find method.

HTH
Cordially
Pascal

"Arne Hegefors" a écrit dans le
message de news: ...
Hi! I have a macro that searches through a list of data using objects. I
want
to see if a cell contains a certain value and if so then do something. The
cell can contain eg: AUSTRIA GVB 2012 JUL 5.0%. However, I am just
interested
in AUSTRIA. The rest does not matter. I have a list of the words I am
looking
for. Basically all I want to know is how can I search a cell for a certain
value? Thanks alot!!





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Search for text string

The code below will return a message mox saying "yup" of A1 contains
AUSTRIA anywhere within it's text.
Sub try()
If InStr(1, Cells(1,1), "AUSTRIA", 1) _
Then MsgBox "yup"
End Sub

Arne Hegefors wrote:
Hi! I have a macro that searches through a list of data using objects. I want
to see if a cell contains a certain value and if so then do something. The
cell can contain eg: AUSTRIA GVB 2012 JUL 5.0%. However, I am just interested
in AUSTRIA. The rest does not matter. I have a list of the words I am looking
for. Basically all I want to know is how can I search a cell for a certain
value? Thanks alot!!


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
Search If on text string bob Excel Worksheet Functions 3 February 15th 10 06:49 PM
Nested formula to search a text string and return specific text Barbie Excel Worksheet Functions 10 February 21st 09 07:40 AM
Search for a text string Dan Excel Discussion (Misc queries) 1 November 10th 08 09:09 PM
Search, find or lookup defined text in text string zzxxcc Excel Worksheet Functions 9 September 6th 07 09:37 PM
Search a text file for a string crazybass2 Excel Programming 2 June 21st 05 12:53 AM


All times are GMT +1. The time now is 02:48 PM.

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

About Us

"It's about Microsoft Excel"