Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

60%
+1 −0
Q&A How to add to the value of one cell an amount that depends upon the range of a different cell?

One way is to create a lookup table (sorted ascending) and take advantage of VLOOKUP's is_sorted parameter to opt for "the nearest match (less than or equal to the search key)". Say a table like so...

posted 3y ago by pnuts‭  ·  last activity 3y ago by Alexei‭

Answer
#7: Post undeleted by user avatar Alexei‭ · 2021-05-26T18:08:45Z (almost 3 years ago)
#6: Post deleted by user avatar pnuts‭ · 2020-12-07T15:32:32Z (over 3 years ago)
#5: Post edited by user avatar pnuts‭ · 2020-10-04T01:22:21Z (over 3 years ago)
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F6,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =H7+choose(1+min(int(F7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `H7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F7,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =H7+choose(1+min(int(F7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `H7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
#4: Post edited by user avatar pnuts‭ · 2020-10-04T01:21:40Z (over 3 years ago)
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F6,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =H7+choose(1+min(int(F7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `F7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F6,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =H7+choose(1+min(int(F7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `H7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
#3: Post edited by user avatar pnuts‭ · 2020-10-04T01:20:36Z (over 3 years ago)
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F6,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =F7+choose(1+min(int(F7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `F7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F6,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =H7+choose(1+min(int(F7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `F7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
#2: Post edited by user avatar pnuts‭ · 2020-10-04T01:19:40Z (over 3 years ago)
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F6,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =F7+choose(1+min(int(E7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `F7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
  • One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".
  • Say a table like so:
  • <pre>0 0
  • 5 1
  • 10 2
  • 15 3
  • 20 4
  • 25 5</pre>
  • with the Named Range `Table`. Then a formula such as:
  • =vlookup(F6,Table,2)+H7
  • to determine the supplement and add it to `H7`.
  • This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.
  • However, where the steps are uniform (of `5` each here) a separate table is not required:
  • =F7+choose(1+min(int(F7/5),5),0,1,2,3,4,5)
  • applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible:
  • =H7+min(int(F7/5),5)
  • This adds to `F7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).
  • The above applies to Excel as well.
#1: Initial revision by user avatar pnuts‭ · 2020-10-04T01:14:38Z (over 3 years ago)
One way is to create a lookup table (sorted ascending) and take advantage of [VLOOKUP](https://support.google.com/docs/answer/3093318)'s `is_sorted` parameter to opt for "*the nearest match (less than or equal to the search key)*".

Say a table like so:

<pre>0	0
5	1
10	2
15	3
20	4
25	5</pre>

with the Named Range `Table`. Then a formula such as: 

    =vlookup(F6,Table,2)+H7 

to determine the supplement and add it to `H7`.

This approach could be versatile where changes to the ranges are required and more manageable than adapting a nested IF formula. The table is reasonably intuitive as quite similar to the requirement as expressed in the source question. It would be more so if the columns were switched over, but VOOKUP is simpler than an INDEX/MATCH pair and requires the `search_key` to be on the left of the `range`.

However, where the steps are uniform (of `5` each here) a separate table is not required:

    =F7+choose(1+min(int(E7/5),5),0,1,2,3,4,5) 

applying [CHOOSE](https://support.google.com/docs/answer/3093371), and a (slightly) shorter formula is possible: 

    =H7+min(int(F7/5),5) 

This adds to `F7` the rounded down to integer ([INT](https://support.google.com/docs/answer/3093490)) result of dividing `F7` by the range 'width' (each step is `5`), capped at `5` ([MIN](https://support.google.com/docs/answer/3094017)).

The above applies to Excel as well.