View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Kevin B[_5_] Kevin B[_5_] is offline
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