+ Reply to Thread
Results 1 to 6 of 6

How to refer to back-to-back rows in code

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Question How to refer to back-to-back rows in code

    Hello all,

    I am attempting to write a macro that will ask the user to input a number at the beginning and then use that number for calculation later. Before the calculation however, I would like it to loop through Column B (in example) and check for a sign change. For example in row 11, it is negative and the next row is positive, so then it would take the value of Column C row 11 for its calculation. I'm not sure how to refer to row 11 and row 12 when trying to check for sign change. Any thoughts/comments on this so far? Any help is appreciated.

    Please Login or Register  to view this content.
    example.xlsx

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to refer to back-to-back rows in code

    Your loop doesn't have a For statement. Is this what you are trying to do?

    Please Login or Register  to view this content.
    I think you want to use the Offset(1) to refer too the next row.

  3. #3
    Registered User
    Join Date
    07-17-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: How to refer to back-to-back rows in code

    Yess, that is exactly what I'm trying to do. However, I forgot to mention that the positive and negatives are actually positive and negative numbers. That would change the code a tad bit, correct?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to refer to back-to-back rows in code

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-17-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: How to refer to back-to-back rows in code

    Thank you, that is what I'm looking for. Learned quite a bit from this, thanks again!

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How to refer to back-to-back rows in code

    You're welcome. Glad to help out, and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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] Stop Vlookup bringing back 0's or #REF! and bring back blanks instead
    By Carling73 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-30-2013, 04:43 PM
  2. Refer Back to the Cell Returned by Address Function
    By deli9680 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-26-2013, 10:54 AM
  3. Need some help geting VBA code to work back to back.
    By BrettRCourtney in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-14-2013, 11:00 AM
  4. Replies: 0
    Last Post: 10-01-2010, 08:16 AM
  5. Replies: 5
    Last Post: 05-21-2009, 10:07 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