+ Reply to Thread
Results 1 to 7 of 7

Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. etc

  1. #1
    Registered User
    Join Date
    03-31-2022
    Location
    Victoria, Australia
    MS-Off Ver
    Professional Plus 2016
    Posts
    4

    Question Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. etc

    Hi all,
    I've only just found this forum. This is my first post.

    I am looking for some code to perform a simple calculation using the 1st and last number in a column (ie. subtract the last number from the first number and divide the result by 2)
    then perform the same calculation using the 2nd and 2nd last number, then the 3rd and 3rd last number etc.With the result of the calculation being output to the cell adjacent to the first number used in the calculation.
    The column of input data will be of varying lengths and the numbers in the column will be separated by blank cells of varying intervals. there will always be an even number of entries.
    Please see attached example to better explain my problem.

    Thanks.
    Attached Files Attached Files
    Last edited by Pat T; 03-31-2022 at 05:22 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. e

    Try
    Please Login or Register  to view this content.

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. e

    Please Login or Register  to view this content.
    Quang PT

  4. #4
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. e

    as a formula it is a bit ugly

    in b2 as an array so enter with control enter
    =IF(OR(A2>="",COUNT($b$1:b1)>=INT(COUNT($A$1:$A$43)/2)),"",(A2-INDEX($A$2:$A$43,LARGE(IF($A$2:$A$43<>"",ROW($A$2:$A$43)-1,""),1+COUNT($b$1:b1))))/2)

  5. #5
    Registered User
    Join Date
    03-31-2022
    Location
    Victoria, Australia
    MS-Off Ver
    Professional Plus 2016
    Posts
    4

    Re: Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. e

    Thanks jindon. have tested and works great. you don't know how long i've been trying to figure that out. so thank you.
    awesome.

  6. #6
    Registered User
    Join Date
    03-31-2022
    Location
    Victoria, Australia
    MS-Off Ver
    Professional Plus 2016
    Posts
    4

    Re: Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. e

    Quote Originally Posted by bebo021999 View Post
    Please Login or Register  to view this content.
    Thanks for the solution bebo021999. This does the job.

  7. #7
    Registered User
    Join Date
    03-31-2022
    Location
    Victoria, Australia
    MS-Off Ver
    Professional Plus 2016
    Posts
    4

    Re: Perform calculation with 1st and last number in a column, then 2nd and 2nd last num. e

    Quote Originally Posted by davsth View Post
    as a formula it is a bit ugly

    in b2 as an array so enter with control enter
    =IF(OR(A2>="",COUNT($b$1:b1)>=INT(COUNT($A$1:$A$43)/2)),"",(A2-INDEX($A$2:$A$43,LARGE(IF($A$2:$A$43<>"",ROW($A$2:$A$43)-1,""),1+COUNT($b$1:b1))))/2)
    Thanks for the suggestion davsth. its nice to have a formula option too. so thank you.

+ 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. Replies: 16
    Last Post: 04-04-2021, 11:54 AM
  2. Replies: 3
    Last Post: 01-28-2021, 09:11 AM
  3. [SOLVED] Search for a value in a column and from that row up perform calculation
    By BlackDaniels in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-15-2020, 02:22 PM
  4. [SOLVED] Formula to perform calculation with n number of rows based on cell value
    By ironfelix717 in forum Excel General
    Replies: 12
    Last Post: 11-21-2017, 04:58 PM
  5. [SOLVED] Macro to create array and then perform calculation in column C
    By jaredmccullough in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 06-29-2017, 04:52 PM
  6. [SOLVED] How to perform automatic calculation of specific ranges in a column
    By thkatag in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-18-2012, 11:37 AM
  7. perform a calculation on the number part of the string
    By bilbonvidia in forum Excel General
    Replies: 2
    Last Post: 07-13-2007, 04:47 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