+ Reply to Thread
Results 1 to 4 of 4

Need help with cells.find and do if looping

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    35

    Need help with cells.find and do if looping

    I have been trying to adapt the following code

    Please Login or Register  to view this content.
    What I need it to do is look only in column C for cells that are not = to "#N/A"
    currently it finds N/A's in Multiple columns and returns an entry for each.

    I realize the union code is not required for this example but it will be for other iterations of the macro
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Need help with cells.find and do if looping

    Hello wellsw,

    Try this...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,768

    Re: Need help with cells.find and do if looping

    The reason that the Find is looking in all cells, and not just column C, is that is what is specified. The code specifies
    Please Login or Register  to view this content.
    and Cells is a reference to the entire worksheet. You have used

    Please Login or Register  to view this content.
    but then the code never actually takes advantage of that With. To do that you want something like this:

    Please Login or Register  to view this content.
    The .Find means "Do a find on the range I have specified in my With statement."

    However, that doesn't solve your problem I just am trying to do a little education there. The bigger problem is that a Find can only find a string, it cannot find cells that fail to match a string. That would have to be done as an explicit loop. I have suggested one solution here. You will also note that I declare all variables, which I highly recommend (along with Option Explicit, which is automatically provided in new modules if you set Tools, Options, Require Variable Declaration).

    I have tested this code on your file and I believe it does what you want:

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    12-05-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Need help with cells.find and do if looping

    6StringJazzer
    That is exactly what I needed... and thanks so much for breaking it down for me... that makes it easier to understand so I can adopt it for other applications!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Looping Find Function
    By hkayani08 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2012, 10:05 AM
  2. looping in the find command
    By jmgriffin101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2009, 06:50 AM
  3. Looping Find
    By Gus80 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2008, 06:34 PM
  4. Looping the Find Function
    By maverick_abhi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2007, 01:54 AM
  5. Looping Macro - using find
    By DBaggs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2005, 01:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1