Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

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

0
Seamus2626
Asked:
Seamus2626
  • 2
  • 2
1 Solution
 
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
 
StephenJRCommented:
That should be:

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now