+ Reply to Thread
Results 1 to 4 of 4

Looping an if statement with row number variable

  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    63

    Looping an if statement with row number variable

    Hello all, I have a simple if statement that looks like this:
    Please Login or Register  to view this content.
    It basically compares 2 cells to each other (A5 and K22), and if they match, and the other cell in the same row is not blank (B22), then it unhides the entire row.

    I need to do that for each row from 22 to 218. Obviously I don't want to rewrite this if statement 200 times, but I am not sure how to make a loop that does it automatically.

    I'm sure its fairly simple, but I am really not good with loops. Any assistance with this would be greatly appreciated

    Chris

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Looping an if statement with row number variable

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Looping an if statement with row number variable

    Sounds like you want to hide rows that are separated by 17 rows if they meet your criteria, beginning at row 5, and ending at row 201 (17 rows down from that would be row 218). If that's the case, try:
    Please Login or Register  to view this content.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  4. #4
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Looping an if statement with row number variable

    Explanatory note to previously posted code...What the code "should" do (untested) is check to see if A5 and K22 match, and that B22 is not 0. It then compares A6, K23 and B23| A7, K24 and B24 etc.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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