Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default How to make my code recognize one letter in a text in a cell???

Hi,

I want to write a code that can go thrue all my cells in which there is text
looking somewhat like this:

E304_Gv070524f 3,7_3,7_01
E304_Gv070524o 3,7_3,7_01
E304_Gv070905f 3_3_01
E304_Gv070905o 3_3_01
E304_Gv071220f 2_2_01
E304_Gv071220o 2,1_2_01
E304_Gv071220o 2_2_01
E304_Gv080313f 3,5_3,5_01

in every of these lines there is a "o" or an "f". I want my code to select
all the cells in wich letter "o" is present.. how can I do that?? The letters
are not always in the same place in the cells..



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to make my code recognize one letter in a text in a cell???

Select the range of cells you want to search and run:

Sub FindO()
Dim r As Range, rfind As Range
Dim v As String
Set rfind = Nothing
Set r = Selection
For Each rr In r
v = rr.Value
If InStr(v, "o") 0 Then
If rfind Is Nothing Then
Set rfind = rr
Else
Set rfind = Union(rfind, rr)
End If
End If
Next
If rfind Is Nothing Then
Else
rfind.Select
End If
End Sub

--
Gary''s Student - gsnu200827


"Ksenija" wrote:

Hi,

I want to write a code that can go thrue all my cells in which there is text
looking somewhat like this:

E304_Gv070524f 3,7_3,7_01
E304_Gv070524o 3,7_3,7_01
E304_Gv070905f 3_3_01
E304_Gv070905o 3_3_01
E304_Gv071220f 2_2_01
E304_Gv071220o 2,1_2_01
E304_Gv071220o 2_2_01
E304_Gv080313f 3,5_3,5_01

in every of these lines there is a "o" or an "f". I want my code to select
all the cells in wich letter "o" is present.. how can I do that?? The letters
are not always in the same place in the cells..



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default How to make my code recognize one letter in a text in a cell??



Hi again,
I need more help, am very new at this..
I wrote like this:

Sub FindO()

ActiveCell = L2
Do While Not ActiveCell = Empty

Dim r As Range, rfind As Range
Dim v As String
Set rfind = Nothing
Set r = Selection
For Each rr In r
v = rr.Value
If InStr(v, "o") 0 Then
If rfind Is Nothing Then
Set rfind = rr
Else
Set rfind = Union(rfind, rr)
End If
End If
Next
If rfind Is Nothing Then
Else
rfind.Select
End If
ActiveCell = ActiveCell.Offset(1, 0)
Loop
End Sub

But now it is only deleting the value in the first cell where there is a
"o", and nothing else..

"Gary''s Student" skrev:

Select the range of cells you want to search and run:

Sub FindO()
Dim r As Range, rfind As Range
Dim v As String
Set rfind = Nothing
Set r = Selection
For Each rr In r
v = rr.Value
If InStr(v, "o") 0 Then
If rfind Is Nothing Then
Set rfind = rr
Else
Set rfind = Union(rfind, rr)
End If
End If
Next
If rfind Is Nothing Then
Else
rfind.Select
End If
End Sub

--
Gary''s Student - gsnu200827


"Ksenija" wrote:

Hi,

I want to write a code that can go thrue all my cells in which there is text
looking somewhat like this:

E304_Gv070524f 3,7_3,7_01
E304_Gv070524o 3,7_3,7_01
E304_Gv070905f 3_3_01
E304_Gv070905o 3_3_01
E304_Gv071220f 2_2_01
E304_Gv071220o 2,1_2_01
E304_Gv071220o 2_2_01
E304_Gv080313f 3,5_3,5_01

in every of these lines there is a "o" or an "f". I want my code to select
all the cells in wich letter "o" is present.. how can I do that?? The letters
are not always in the same place in the cells..



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to make my code recognize one letter in a text in a cell??

Erase the old versions. Try this:

Sub FindO()
Dim r As Range, rfind As Range
Dim v As String
Set rfind = Nothing
Set r = Range("L2:L65536")
For Each rr In r
v = rr.Value
If v = "" Then Exit For
If InStr(v, "o") 0 Then
If rfind Is Nothing Then
Set rfind = rr
Else
Set rfind = Union(rfind, rr)
End If
End If
Next
If rfind Is Nothing Then
Else
rfind.Select
End If
End Sub


This version begins with cell L2 and works its way downward until it finds
the first blank.
--
Gary''s Student - gsnu200827


"Ksenija" wrote:



Hi again,
I need more help, am very new at this..
I wrote like this:

Sub FindO()

ActiveCell = L2
Do While Not ActiveCell = Empty

Dim r As Range, rfind As Range
Dim v As String
Set rfind = Nothing
Set r = Selection
For Each rr In r
v = rr.Value
If InStr(v, "o") 0 Then
If rfind Is Nothing Then
Set rfind = rr
Else
Set rfind = Union(rfind, rr)
End If
End If
Next
If rfind Is Nothing Then
Else
rfind.Select
End If
ActiveCell = ActiveCell.Offset(1, 0)
Loop
End Sub

But now it is only deleting the value in the first cell where there is a
"o", and nothing else..

"Gary''s Student" skrev:

Select the range of cells you want to search and run:

Sub FindO()
Dim r As Range, rfind As Range
Dim v As String
Set rfind = Nothing
Set r = Selection
For Each rr In r
v = rr.Value
If InStr(v, "o") 0 Then
If rfind Is Nothing Then
Set rfind = rr
Else
Set rfind = Union(rfind, rr)
End If
End If
Next
If rfind Is Nothing Then
Else
rfind.Select
End If
End Sub

--
Gary''s Student - gsnu200827


"Ksenija" wrote:

Hi,

I want to write a code that can go thrue all my cells in which there is text
looking somewhat like this:

E304_Gv070524f 3,7_3,7_01
E304_Gv070524o 3,7_3,7_01
E304_Gv070905f 3_3_01
E304_Gv070905o 3_3_01
E304_Gv071220f 2_2_01
E304_Gv071220o 2,1_2_01
E304_Gv071220o 2_2_01
E304_Gv080313f 3,5_3,5_01

in every of these lines there is a "o" or an "f". I want my code to select
all the cells in wich letter "o" is present.. how can I do that?? The letters
are not always in the same place in the cells..



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
make cell contain only 1 letter/number then tab automatically Ron Lynn Jr Excel Discussion (Misc queries) 3 September 21st 08 10:22 PM
How to make First letter of the cell in capital letter Irshad Alam Excel Programming 17 September 7th 08 04:14 PM
How to make a conditional format recognize a formula in a cell WC Turner Excel Discussion (Misc queries) 5 September 14th 06 12:43 AM
Formula to recognize text only in a cell Jim May Excel Worksheet Functions 11 March 7th 06 11:40 PM
How to make a cell recognize multiple text strings? Tourcat Excel Worksheet Functions 1 February 8th 05 08:29 PM


All times are GMT +1. The time now is 05:29 PM.

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"