Solved

Excel VBA FindNext Error

Posted on 2007-03-23
2
2,335 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:murbro
[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 500 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:murbro
ID: 18883737
thanks very much
0

Featured Post

Technology Partners: 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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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…

726 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