ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search cell for string (https://www.excelbanter.com/excel-programming/400806-search-cell-string.html)

Arne Hegefors

Search cell for string
 
Hi! I search column A in an excel file fo ra certain expression. The
expression might look like: G BP730 080708_88571. However the cell I am
trying to locate will only contain part of this string eg G BP730 080708. How
can I do this? Many thanks!



Gary''s Student

Search cell for string
 
Try this:

Sub arneee()
Dim expression As String, v As String
expression = "G BP730 080708_88571"
Set r = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each rr In r
v = rr.Value
If InStr(expression, v) 0 And Len(v) 0 Then
MsgBox (rr.Address & Chr(10) & rr.Value)
Exit Sub
End If
Next
End Sub

--
Gary''s Student - gsnu200754


"Arne Hegefors" wrote:

Hi! I search column A in an excel file fo ra certain expression. The
expression might look like: G BP730 080708_88571. However the cell I am
trying to locate will only contain part of this string eg G BP730 080708. How
can I do this? Many thanks!




All times are GMT +1. The time now is 09:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com