+ Reply to Thread
Results 1 to 7 of 7

Macro to loop through dynamic number of rows checking adjacent for certain criteria

  1. #1
    Registered User
    Join Date
    04-12-2014
    Location
    london, england
    MS-Off Ver
    Excel 2013
    Posts
    4

    Macro to loop through dynamic number of rows checking adjacent for certain criteria

    OK I have a complicated (for me anyway!) bit of code to write:

    I need my macro to go through X number of rows,

    and for each row I need it to check all the columns to the right (this will also be dynamic),

    if it finds a "Y" I need it to check the corresponding value in row 4 for "Yes",

    if every "Y" corresponds to a "Yes" then i need it to print "Ready".

    If any of the "Y" correspond to a "no" I need to to print "Not Ready".



    Any help at all would be greatly appreciated!! I'm running excel 2013. Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to loop through dynamic number of rows checking adjacent for certain criteria

    Just to make sure I understand. What do you mean by "print "Ready"". Is this a literal statement? As in you actually want a printer to print out a sheet a paper with the words "Ready" on it?

    if it finds a "Y" I need it to check the corresponding value in row 4 for "Yes",
    Do you mean row 1?

  3. #3
    Registered User
    Join Date
    04-12-2014
    Location
    london, england
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: Macro to loop through dynamic number of rows checking adjacent for certain criteria

    Hi stnkynts,

    Sorry - I do mean row one and no I just want it to say "Ready" or "Not Ready" in column A of the appropriate row.

    Thank you!!

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to loop through dynamic number of rows checking adjacent for certain criteria

    What about rows in which there is both a "Y" corresponding to a "Yes" and a "Y" corresponding to a "No". Row 13 for example. How should those be treated. Should it say "Might Be Ready"?

  5. #5
    Registered User
    Join Date
    04-12-2014
    Location
    london, england
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: Macro to loop through dynamic number of rows checking adjacent for certain criteria

    So if any "Y"s correspond to a No then it should say "not ready", for it to say "ready" every single "Y" in that particular row must correspond to a Yes.

    I really appreciate this btw!

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to loop through dynamic number of rows checking adjacent for certain criteria

    Here you go. Note my comments on how I approached the problem to try to minimize the time it takes for the code to run. Even still, it took about 2 seconds to run on my computer. It is the way it is when you need to go through each individual cell. There are some other more advanced ways to do it, but this works and doesn't take up to much of my time.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-12-2014
    Location
    london, england
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: Macro to loop through dynamic number of rows checking adjacent for certain criteria

    Oh my god you're a rock star!

    Thank you so much, it works perfectly you absolute legend! I am in your debt.

+ 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] macro to autofil formula based on number of rows on adjacent column
    By kramtelbuab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2013, 08:28 PM
  2. [SOLVED] Loop through named range backwards and populate based on criteria from adjacent cells
    By CDEG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2013, 05:56 AM
  3. macro for checking each row and comparing adjacent columns
    By jkmasurkar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2013, 10:59 PM
  4. VBA Loop for averaging multiple cells adjacent to date criteria column
    By Swampy79 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2013, 10:08 PM
  5. Macro to loop through rows, if criteria is met then certain action is performed
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 06-08-2011, 04:20 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