Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find a String
Hi, I have this problem:
I need to check, whether in a cell there is or not string, beginning with "Access" I tried to make a macro, but I am not able to do it... Example of text in cells: Calls to Eurotel Calls to Orange Access No. 45687 Local Calls Access No. 15789 Calls to Orange Calls to Eurotel Access No. 78896 I tried to write a code like: Sub Check() Dim MyString As String Do MyString = ActiveCell.Value If MyString = "Access*" Then MsgBox "I've found one!" End If ActiveCell.Offset(1, 0).Select Loop Until MyString = "Access*" End Sub Any idea please? Marian |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find a String
Marian,
Use the LIKE operator. E.g., If MyString Like "Access*" Then -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Marian" wrote in message ... Hi, I have this problem: I need to check, whether in a cell there is or not string, beginning with "Access" I tried to make a macro, but I am not able to do it... Example of text in cells: Calls to Eurotel Calls to Orange Access No. 45687 Local Calls Access No. 15789 Calls to Orange Calls to Eurotel Access No. 78896 I tried to write a code like: Sub Check() Dim MyString As String Do MyString = ActiveCell.Value If MyString = "Access*" Then MsgBox "I've found one!" End If ActiveCell.Offset(1, 0).Select Loop Until MyString = "Access*" End Sub Any idea please? Marian |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find a String
If you are looping down a long column, would using the Find command work for
you? Sub Demo() On Error Resume Next With Columns("A:A") .Find( _ What:="Access*", _ After:=.Cells(1), _ LookIn:=xlFormulas, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False).Offset(0, 1).Activate End With If Err.Number = 91 Then 'Object variable or With block variable not set MsgBox "None Found" ElseIf Err.Number 0 Then MsgBox "Some other error!", vbExclamation Else MsgBox "Found One!", vbInformation End If End Sub -- Dana DeLouis Using Windows XP & Office XP = = = = = = = = = = = = = = = = = "Marian" wrote in message ... Hi, I have this problem: I need to check, whether in a cell there is or not string, beginning with "Access" I tried to make a macro, but I am not able to do it... Example of text in cells: Calls to Eurotel Calls to Orange Access No. 45687 Local Calls Access No. 15789 Calls to Orange Calls to Eurotel Access No. 78896 I tried to write a code like: Sub Check() Dim MyString As String Do MyString = ActiveCell.Value If MyString = "Access*" Then MsgBox "I've found one!" End If ActiveCell.Offset(1, 0).Select Loop Until MyString = "Access*" End Sub Any idea please? Marian |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find in string | Excel Worksheet Functions | |||
Find String in another string - only between spaces | Excel Worksheet Functions | |||
Find Many String options in ONE String | Excel Worksheet Functions | |||
find string within other string | Excel Worksheet Functions | |||
find nth position of a string | Excel Discussion (Misc queries) |