+ Reply to Thread
Results 1 to 5 of 5

Adding a variable range to a formula, depending on values

  1. #1
    Registered User
    Join Date
    08-06-2019
    Location
    Brussels
    MS-Off Ver
    365
    Posts
    3

    Adding a variable range to a formula, depending on values

    I've cracked my head thinking, searching, trying and failing.

    Attached you will find an example of the file.

    In the INPUT, I paste a set of data. The first CALC set I use to swap columns Distance and Height.
    In the FIXED section, there are a number of fixed values every 10 meters.

    The final CALC section is used to calculate the nearest values below and above the fixed value for each KP, along with its height. The problem is that when pasting other INPUT data, there could be more or less points for each KP. In this example, I have 5 points at KP0 and 4 points at KP10. But the next INPUT could very well contain 10 KP0 and 6 KP10 values and so on...

    My question is: is there a way to automatically determine the range of the values at KP0, KP10, ... so I don't have to manually select it every time I copy data in this sheet? If so, how do I set up the formula to calculate the nearest distances with this range?

    Please keep in mind that the KP limit could reach around 3000.


    Very much obliged.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: Adding a variable range to a formula, depending on values

    Welcome to the forum.

    Once we understand what you are trying to do, there will be a solution. Unfortunately, at the moment, I don't get it.

    Why, for instance, do you need to swap the height and distance columns and present them again?

    How do you know what the fixed distances for the KPs will be? How are these calculated?

    What is the purpose of the data on the extreme right?

    Perhaps if you could explain how you intend to use this data, it might help us (me) to understand what you are after,
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-06-2019
    Location
    Brussels
    MS-Off Ver
    365
    Posts
    3

    Re: Adding a variable range to a formula, depending on values

    Thanks

    I swap them to determine the height for the corresponding value for Distance A at the far right with VLOOKUP.

    The fixed distances for the different KP's are given. The purpose of the excel sheet is to calculate the height at this given KP, but unfortunately the INPUT data rarely has this exact value. So I want to calculate the interpolated height out of the two nearest values for each KP.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,000

    Re: Adding a variable range to a formula, depending on values

    Odd description, but I think I understand. A slight change of layout and variants of this formula:

    =AGGREGATE(14,6,$C$3:$C$11/(($D$3:$D$11=$L3)*($C$3:$C$11<=$J3)),1)

    in the 4 columns, then dragged down as far as needed. No need to array enter, but you may need ; as the separator instead of ,
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Registered User
    Join Date
    08-06-2019
    Location
    Brussels
    MS-Off Ver
    365
    Posts
    3

    Re: Adding a variable range to a formula, depending on values

    A million times thanks! Just what I needed!

+ 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] Variable image depending on entered values
    By Solvax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2018, 11:59 AM
  2. Adding and subtracting set values depending on multiple criteria
    By Rekragisao in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-19-2017, 11:40 AM
  3. Variable Data Range Depending on Date
    By joerv007 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-11-2017, 11:03 AM
  4. Adding values depending on dates
    By Ebonite in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-31-2016, 09:40 AM
  5. [SOLVED] Adding Values in Multiple Offset Cells depending on the value of a different cell
    By lottidotti in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-19-2012, 11:35 AM
  6. Unique values depending on variable
    By Skybeau in forum Excel General
    Replies: 2
    Last Post: 11-12-2009, 05:21 AM
  7. Adding Row Values depending on Corresponding Rows
    By chr5648 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2007, 05:26 PM

Tags for this Thread

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