+ Reply to Thread
Results 1 to 4 of 4

Need to run a simple command (=A2-A3) but only on 2 cells that come after a certain value

  1. #1
    Registered User
    Join Date
    08-19-2011
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Need to run a simple command (=A2-A3) but only on 2 cells that come after a certain value

    Here is a basic scenario. I am looking at customer records and I want to find the number of days since their last and previous order.

    Let's say column A has the following info:

    1 Customer Name John
    2 03/09/15
    3 01/02/13
    4 12/12/12
    5 11/01/11
    6 Customer Name Frank
    7 03/09/15
    8 01/02/13
    9 12/12/12
    10 11/01/11

    So I would need to take the first 2 cells AFTER the cell the contains the value "customer" and subtract them to find the amount of days between the two. The sheet has thousands of lines. Thanks!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Need to run a simple command (=A2-A3) but only on 2 cells that come after a certain va

    in B1
    =IF(LEFT(A1,8)="Customer",A2-A3,"")
    and copy down
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    08-19-2011
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Need to run a simple command (=A2-A3) but only on 2 cells that come after a certain va

    AWESOME! Thanks. One last question. If the cell with the value "customer" has some other extraneous data in the cell can I just have your formula look for a cell containing "customer" instead of that exact left count? I appreciate it!

  4. #4
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Need to run a simple command (=A2-A3) but only on 2 cells that come after a certain va

    Hi,

    Try this


    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Cheers
    Albert



    Please don't forget to thank those who helped by clicking on Add Reputation * and please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools-> Mark thread as Solved).

+ 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] How to execute a Command Button (simple)
    By cronshd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2012, 02:05 PM
  2. Simple Loop command
    By chrismann85 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-24-2011, 08:26 AM
  3. Simple IF command for novice!
    By kev_stor in forum Excel General
    Replies: 1
    Last Post: 02-07-2008, 11:23 AM
  4. Replies: 0
    Last Post: 02-21-2006, 12:10 PM
  5. [SOLVED] Error running simple command
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2005, 05:06 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