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

Hi!


I need to program a VBA fonction who will check in every cell of a
specific column to find out if the cells contains a specific string...

By exemple, I want to find out if the string "server" is in any cells
of a column.

I cannot use something like Cells(row,column).Value because the cells
can have something else like "back-up,server,test etc..."

It is also possible that no cells will have this string... I've tried
to use the
Find Method but it give me an error if no cell have the string...

A way to handle this error could also be usefull..

Can anyone help me about this???


Thanks!

Samuel Levesque
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Find specific text in a string

Use

Cells(row,column).Value Like "*Server*"

--

HTH

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


"Samuel" wrote in message
m...
Hi!


I need to program a VBA fonction who will check in every cell of a
specific column to find out if the cells contains a specific string...

By exemple, I want to find out if the string "server" is in any cells
of a column.

I cannot use something like Cells(row,column).Value because the cells
can have something else like "back-up,server,test etc..."

It is also possible that no cells will have this string... I've tried
to use the
Find Method but it give me an error if no cell have the string...

A way to handle this error could also be usefull..

Can anyone help me about this???


Thanks!

Samuel Levesque



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Find specific text in a string

Note that this won't find "server", since Like is case sensitive unless
Option Compare Text is included in the module.

If you have mixed cases, you could use

LCase(Cells(row, column).Text) Like "*server*"

In article ,
"Bob Phillips" wrote:

Use

Cells(row,column).Value Like "*Server*"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Find specific text in a string

One way:


Dim bWordExists As Boolean
bWordExists = Application.CountIf(Columns(1).Cells, "*server*") 0
If bWordExists Then MsgBox "found ""server"""

Another:

Dim rFound As Range
Set rFound = Columns(1).Find( _
What:="server", _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not rFound Is Nothing Then _
MsgBox "Found ""server"" at " & rFound.Address





In article ,
(Samuel) wrote:

I need to program a VBA fonction who will check in every cell of a
specific column to find out if the cells contains a specific string...

By exemple, I want to find out if the string "server" is in any cells
of a column.

I cannot use something like Cells(row,column).Value because the cells
can have something else like "back-up,server,test etc..."

It is also possible that no cells will have this string... I've tried
to use the
Find Method but it give me an error if no cell have the string...

A way to handle this error could also be usefull..

Can anyone help me about this???

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Find specific text in a string

This procedure will but the text "Server Found" in the cell directly to the
left of the cell value beingn evaluated.

Sub Server()

Dim lRow As Long
Dim lCol As Long
Dim strVal As String
Dim varArray As Variant

lRow = ActiveCell.Row
lCol = ActiveCell.Column

strVal = Cells(lRow, lCol).Value

Do Until strVal = ""
varArray = Split(strVal)
For Each Item In varArray
If Item = "Server" Then
Cells(lRow, lCol + 1).Value = "Server Found"
End If
Next
lRow = lRow + 1
strVal = Cells(lRow, lCol).Value
Loop

"Samuel" wrote:

Hi!


I need to program a VBA fonction who will check in every cell of a
specific column to find out if the cells contains a specific string...

By exemple, I want to find out if the string "server" is in any cells
of a column.

I cannot use something like Cells(row,column).Value because the cells
can have something else like "back-up,server,test etc..."

It is also possible that no cells will have this string... I've tried
to use the
Find Method but it give me an error if no cell have the string...

A way to handle this error could also be usefull..

Can anyone help me about this???


Thanks!

Samuel Levesque



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
Find specific info within a text string using VBA laavista Excel Discussion (Misc queries) 2 May 20th 09 06:37 PM
How to Find Specific Text in a Text String Confused_in_Houston[_2_] Excel Discussion (Misc queries) 2 January 26th 09 08:17 PM
Find specific value in a string Lost in Microbiology Excel Discussion (Misc queries) 8 May 16th 07 09:58 AM
can you find specific text in a string ignoring any other text chriscp Excel Discussion (Misc queries) 1 September 18th 05 09:54 PM
Find specific text in a string Kilcup Excel Programming 5 June 10th 04 04:29 PM


All times are GMT +1. The time now is 10:36 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"