stopping at text....

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 text. Is there any way to
write a simple if statement that says "If next cell does not equal an
integer, exit sub"?

example: in the below example I find the load case (say load1) then
search under it for node 404. As 404 is not there I need it to stop at
load2 and not continue to the 404 value.

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

thanks for your help.
 
J

Jim Cone

n,
'---------------------
Sub StopAtText()
Dim rngList As Excel.Range
Dim rngCell As Excel.Range
Set rngList = Range("B5:B10")
For Each rngCell In rngList
If Not IsNumeric(rngCell) Then Exit For
' or
' If Val(rngCell) = 0 Then Exit For
' or
' If Not Left(rngCell, 1) Like "#" Then Exit For
Next
End Sub
'-----------------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"nelg" 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 text. Is there any way to
write a simple if statement that says "If next cell does not equal an
integer, exit sub"?

example: in the below example I find the load case (say load1) then
search under it for node 404. As 404 is not there I need it to stop at
load2 and not continue to the 404 value.

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

thanks for your help.
nelg
 
N

nelg

Thanks Jim that worked great now onto the second problem. See the sam
thread for the change
 

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

Similar Threads


Top