Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6077081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:40:51+00:00 2026-05-23T10:40:51+00:00

I am working with find functions in VBA Excel, so when I ran into

  • 0

I am working with find functions in VBA Excel, so when I ran into problems I pulled some example code from the help provided in Excel. I took their code that illustrates a basic
find function and pasted it into a macro. On running the macro, I get a “Runtime error ’91′” and the debugger highlights the line of code containing the angled brackets <>. These are the part of the code that I cannot understand.

Can anyone tell me what these brackets represent?

Sub exampleFindReplace()

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
    firstAddress = c.Address
    Do
        c.Value = 5
        Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:40:52+00:00Added an answer on May 23, 2026 at 10:40 am

    The <> operator means c.Address Is Not Equal To firstAddress.

    In a C-style language this would be equivalent to c.Address != firstAddress.


    Side note, I think you are getting error 91 (Object variable or With block variable not set.) because the line of code Loop While Not c Is Nothing And c.Address <> firstAddress will always try to execute the second condition (c.Address <> firstAddress) even if the first (While Not C Is Nothing) evaluates to false. Thus the call on c.Address will raise the exception.

    Try writing the code like this as it will not allow that to happen:

    Sub exampleFindReplace()
    
    With Worksheets(1).Range("a1:a500")
    Set c = .Find(2, LookIn:=xlValues)
    If Not c Is Nothing Then
        firstAddress = c.Address
        Do
            c.Value = 5
            Set c = .FindNext(c)
            If c Is Nothing Then Exit Do
        Loop While c.Address <> firstAddress
    End If
    End With
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I find it hard to find some working examples of Cocoa/Carbon framework functions, whereas
While working with DB, I find useful using some tools, that help me to
I am working on some code that mixes OCaml and C, the functions caml_release_runtime_system()
Where can i find some .Net or conceptual resources to start working with Natural
I am having difficulty trying to code these functions. They are not working properly
I'm working on a project where I need to find which functions get called
Some of the functions for working with Arrows are quite handy to use on
I'm making a dropdown menu and it's working perfectly with the slideUp/slideDown functions from
I'm working on using Find/Replace to change a bunch of labels to DataBound text.
Many times we find ourselves working on a problem, only to figure out the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.