+ Reply to Thread
Results 1 to 3 of 3

Code for nested if-then statements in a loop

  1. #1
    Registered User
    Join Date
    07-29-2006
    Posts
    85

    Code for nested if-then statements in a loop

    I am unfortunately not able to post my grid at the moment so I will do the best I can to explain the logic plan I had laid out.

    Column A = Date
    Column C = Job number, String, Example '1005548714023018
    Column D = Product
    Column H = Amount
    Column I = Units
    x = range
    y = range

    Search H
    If negative value found return row number x
    Return String value in C&x
    Search C for match to C&x and return row number y
    If all following true, cut and paste rows x and y to new sheet
    A&y>=A&x-30 ''within 30 days
    D&x=D&y
    I&x=I&y
    If any false, highlight rows x and y
    Continue until last row in Column H

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Code for nested if-then statements in a loop

    Quote Originally Posted by livifivil View Post
    ... Return String value in C&x
    Search C for match to C&x and return row number y ...
    Is it not one and the same ?
    Try, but without an example, there is no guarantee that it will work at all.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-29-2006
    Posts
    85

    Re: Code for nested if-then statements in a loop

    You're correct and I think that's where I am getting held up. I think your code may work. I will not get to test it until tomorrow but thanks so much for the help. The only thing I didn't see, but now realize I didn't mention, is that if there is no match in C to move on to the next negative value in H. But again, I am not sure how to get past the fact that my code just matches itself. I have to think about this more. Thanks again for the help.

+ 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] Nested Do While Loop Statements with Active Cell Properties on 2 open spreadsheets
    By Seth_ in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-11-2016, 10:27 AM
  2. [SOLVED] Nested IF statements are returning FALSE values - cannot find error in code!
    By apex_chio in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-03-2013, 11:01 PM
  3. Nested For Loop + If Statements Error
    By cinarbe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2012, 10:41 AM
  4. [SOLVED] replacing nested if statements with some kind of VBA loop?
    By cwyn in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-27-2012, 01:46 PM
  5. Code executes 8 times without loop statements. Why?
    By contaminated in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-08-2010, 05:02 PM
  6. For each loop nested; getting stuck on one cell in first iteration of nested loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2009, 11:54 AM
  7. Replies: 12
    Last Post: 05-15-2009, 08:38 AM

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