text within a string

N

nelg

G'day guys, I know there is a simple answer to this. I am searching a
column of values and want to stop when I hit a certain string of text.
Problem is it will be in larger string.

example: in the below example I find the load case (say load1) but
load1 is in a larger string.

this is load1
401
405
410
417
418
this is load2
404
407
413
415
418
419

thanks for your help.
 
J

Jim Cone

n,
Check out the InStr function in VBA help.
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"nelg"
<[email protected]>
wrote in message

G'day guys, I know there is a simple answer to this. I am searching a
column of values and want to stop when I hit a certain string of text.
Problem is it will be in larger string.
example: in the below example I find the load case (say load1) but
load1 is in a larger string.

this is load1
401
405
410
417
418
this is load2
404
407
413
415
418
419

thanks for your help.
nelg
 
G

Gary Keramidas

tom just posted this earlier today to help someone out.

see if it helps you

Option Explicit
Dim rng As Range, rng1 As Range
Dim myVar As String
Sub test()
myVar = "this is load1"
Set rng = Range("a1:a13")

Set rng1 = rng.Find(myVar)
If Not rng1 Is Nothing Then
MsgBox myVar & " found at " & rng1.Address
Else
MsgBox myVar & " was not found in " & rng.Address
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top