Solved

limit search in code

Posted on 2011-09-29
4
155 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now