Solved

limit search in code

Posted on 2011-09-29
4
157 Views
Last Modified: 2012-05-12
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
Comment
Question by:Seamus2626
  • 2
  • 2
4 Comments
 

Author Comment

by:Seamus2626
ID: 36814982
Or even better, if the code counted Column A and used that as its indicator to how many rows to search...........
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 36815145
Seamus - try this:

With sheet1.range("J1",sheet1.range("J" & rows.count).end(xlup))
0
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 36815149
That should be:

With sheet1.range("J1:J" & sheet1.range("A" & rows.count).end(xlup).row)
0
 

Author Closing Comment

by:Seamus2626
ID: 36815203
Perfect, thanks Stephen!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question