+ Reply to Thread
Results 1 to 6 of 6

Looping FindFormat with relative cell update

  1. #1
    Registered User
    Join Date
    10-22-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Looping FindFormat with relative cell update

    Using Excel 2007 and VBA code, I am trying to find all cells in a worksheet with a particular number format ("#,##0.00 ""INR"). For each of these cells I would like to update the cell in the column directly to the right with the value "YES". I have recorded a macro to find the correct format and modified my code to change the value of the cell and everything looks great. However, I cannot figure out the correct way to loop through the sheet once and perform the same function for each of the cells matching the format criteria. Any help is appreciated. Below is my code so far:
    ----

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 10-22-2009 at 02:41 PM. Reason: Added Code Tags

  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: Looping FindFormat with relative cell update

    Hello adamspain,

    This macro will loop through the cells on the ActiveSheet and when a match is found set the cell, one column to the right of the matched cell, equal to "Yes".
    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
    Registered User
    Join Date
    10-22-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Looping FindFormat with relative cell update

    I appreciate the help, unfortunately this is having some inconsistent results. For example it appears that the YES is being applied irrespective of the format check. YES values are being populated throughout the sheet as though the Set FoundIt = Rng.FindNext(FoundIt) statement is not actually finding the next cell with the correct format. Instead it is looping for quite some time to populate a YES value in every row to the right of the last cell with data for that row. Again, seemingly bypassing any check of the format.

  4. #4
    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: Looping FindFormat with relative cell update

    Hello adamspain,

    Sorry it didn't work out, but I don't have Excel 2007. The macro is a composite based on Excel 2003 functionality and the code differences you included in your post.

    The macro is checking all cells on the worksheet as per your request. Whether the code for checking the format is correct, I can not say.
    Using Excel 2007 and VBA code, I am trying to find all cells in a worksheet with a particular number format ("#,##0.00 ""INR").
    For each of these cells I would like to update the cell in the column directly to the right with the value "YES".
    You really need someone who has Excel 2007 to look into why this isn't working.

  5. #5
    Registered User
    Join Date
    10-22-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Looping FindFormat with relative cell update

    Would it make the problem easier to tackle if I said I really only needed to check every cell in column J for the format described. If found then place the yes in the same row in column K directly to the right?

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,985

    Re: Looping FindFormat with relative cell update

    IIRC, FindNext ignores the FindFormat, so try a small tweak:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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