limit search in code

Hi I have a piece of code StephenJR kindly provided me, i am looking for a slight amendment.

instead of searching the entire column (10) i would like it to stop at Row 10,000

Thanks
Seamus
Sub x()
  
Dim rFind As Range, sAddr As String
 
With Sheet1.Columns(10)
    Set rFind = .Find(What:="Sel", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
    If Not rFind Is Nothing Then
        sAddr = rFind.Address
        Do
            rFind.Offset(, 5) = -1 * rFind.Offset(, 5)
            Set rFind = .FindNext(rFind)
         Loop While rFind.Address <> sAddr
    End If
End With
     
End Sub

Open in new window

Seamus2626Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
StephenJRConnect With a Mentor Commented:
That should be:

With sheet1.range("J1:J" & sheet1.range("A" & rows.count).end(xlup).row)
0
 
Seamus2626Author Commented:
Or even better, if the code counted Column A and used that as its indicator to how many rows to search...........
0
 
StephenJRCommented:
Seamus - try this:

With sheet1.range("J1",sheet1.range("J" & rows.count).end(xlup))
0
 
Seamus2626Author Commented:
Perfect, thanks Stephen!
0
All Courses

From novice to tech pro — start learning today.