how to recognize a specific letter in a cell
Hi Ksenija
Try below:
Option Explicit
'----------------------------------------------------------
' Procedure : TestForLetter
' Date : 20090119
' Author : Joergen Bondesen
' Modifyed by : Select cell with Array Letter
' Purpose :
' Note :
'----------------------------------------------------------
'
Sub TestForLetter()
Dim TestLetter As Variant
TestLetter = Array("o", "f")
Dim RRange As Range
Set RRange = Selection
Dim cell As Range
For Each cell In RRange
Dim x As Long
For x = LBound(TestLetter) To UBound(TestLetter)
Dim Testx As Long
Testx = InStr(1, cell, TestLetter(x))
If Testx < 0 Then x = UBound(TestLetter)
Next x
If Testx < 0 Then
Dim SelCell As Range
If SelCell Is Nothing Then
Set SelCell = cell
Else
Set SelCell = Union(SelCell, cell)
End If
End If
Next cell
If Not SelCell Is Nothing Then
SelCell.Select
End If
Set RRange = Nothing
Set SelCell = Nothing
End Sub
--
Best regards
Joergen Bondesen
"Ksenija" skrev i en meddelelse
...
Hi,
I have a lots of cells in which there it written things like these:
E2245_Gv070830f 3,5_3,5_01
E224_Gv070830o 3,5_3,5_01
E224_Gv071220f 4_4_01
I want to select all cells in which letter "o" or "f" is present. How can
i
write this in code?? these letters can have different places in the cell..
|