Cells.find command in Excel Macro Programming


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Cells.find command in Excel Macro Programming

  1. #1
    Robb Guest

    Cells.find command in Excel Macro Programming


    I am writing a macro in Excel. I go to one sheet, find the next item in a
    list, switch to a different sheet, and find the item in a different list.
    I end up with errors when an item that is on the first list is not on the
    second list. I am using On Error goto to try to circumvent this problem,
    but it isn't working. I think I need to have a statement that says something
    like: If cells.find (parameters) = false then goto X subroutine (which goes
    back to the first sheet to find a new item), but this syntax doesn't seem
    to work. Any ideas how I can deal with a search using cells.find that doesn't
    find anything? Thanks for your help. Please email to rfbuzan0@mailbox.sc.edu



  2. #2
    Arthur Wood Guest

    Re: Cells.find command in Excel Macro Programming


    Robb,
    two things:
    1) this is the DATABASE.GENERAL discussion group, and you asked a VBA related
    question that would have a greater chance of being answered in the VB.VBA
    DG.

    2) the Cells.Find method returns a Range object, for the result. If the
    Find DOES NOT succedd, then the Range will be NOTHING (a null object), so
    you can test for this condition with something like:

    Dim r as Range

    set r = Cells.Find(....)
    If not rs is nothing then
    ' you fond what you were looking for, so proceed
    Else
    ' you DID NOT find what you were looking for, so go get the next one
    End if


    Try something like that --- got to this by looking at the Find method in
    the Excel VBA Help system.

    Arthur Wood


    "Robb" <rfbuzan0@mailbox.sc.edu> wrote:
    >
    >I am writing a macro in Excel. I go to one sheet, find the next item in

    a
    >list, switch to a different sheet, and find the item in a different list.
    > I end up with errors when an item that is on the first list is not on the
    >second list. I am using On Error goto to try to circumvent this problem,
    >but it isn't working. I think I need to have a statement that says something
    >like: If cells.find (parameters) = false then goto X subroutine (which goes
    >back to the first sheet to find a new item), but this syntax doesn't seem
    >to work. Any ideas how I can deal with a search using cells.find that doesn't
    >find anything? Thanks for your help. Please email to rfbuzan0@mailbox.sc.edu
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center