Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
make cell contain only 1 letter/number then tab automatically | Excel Discussion (Misc queries) | |||
How to make First letter of the cell in capital letter | Excel Programming | |||
How to make a conditional format recognize a formula in a cell | Excel Discussion (Misc queries) | |||
Formula to recognize text only in a cell | Excel Worksheet Functions | |||
How to make a cell recognize multiple text strings? | Excel Worksheet Functions |