[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Excel VBA FindNext Error

Posted on 2007-03-23
2
Medium Priority
?
2,351 Views
Last Modified: 2013-12-27
Hi

I am using the following VBA code to find all instances of a value in a spreadsheet.
The first Find works but the code falls over on the FindNext part that I have marked with #####

    Dim c As Range
    Dim firstAddress As String
    With Worksheets(oSheetName)
     
        Set c = Cells.Find(What:=oWhat, After:=Range("A1"), LookIn:=oLookin, LookAt:= _
        oLookat, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)
        Call ActionCellContent3(c.Address)
       
        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                Set c = .FindNext(c) '########
   
                Call ActionCellContent3(c.Address)
            Loop While Not c Is Nothing And c.Address <> firstAddress
        End If
    End With
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 18849469
Hi

'Mr Microsoft' recommends replacing the findnext with a duplicate of the find command BUT adding to it the "after:=activecell, " option.  This has worked for me.
0
 

Author Comment

by:Murray Brown
ID: 18883737
thanks very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

650 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