0

I have a sheet in which I have a dropdown that I want users to be able to select a value from. Is it possible to add a value from another cell to the dropdown number after they select from the dropdown? Aka a user selects 3, and the cell displays the number 3+X, where X is a value in another cell.

1
  • 1
    An option is to have the dropdown already include the calculation. Perhaps a bit more info about what you are trying to achieve, why you want to perform the calculation would be helpful. Commented Mar 24 at 11:21

1 Answer 1

0

Google Sheets doesn't include this as a built-in option, but you might use Google Apps Script that is already integrated with Google Sheets.

Example

Below, there is a JavaScript function using the reserved name onEdit. This simple trigger is activated when the spreadsheet is edited by a user using the Google Sheers web app or one of the mobile apps. Please read Extending Google Google Sheets - Google Apps Script and Simple Triggers - Google Apps Script.

  1. Create a new spreadsheet

  2. On A1, insert a dropdown. The Data Validation will be opened.

  3. Replace the default values for the options with numbers

  4. Click Advanced, and in the section If data is invalid, select Show a warning.

  5. Click Done and close the Data Validations side panel.

  6. On B1, add the number to us to multiply the selected value.

  7. Click Extensions > Apps Script.

  8. Set the Apps Script project title.

  9. Replace the default function with the below function.

    function onEdit(e){
       const multiplierRange = e.range.getSheet().getRange('B1');
       const multiplierValue = multiplierRange.getValue();
       e.range.setValue(multiplierValue * e.value);
    }
    
  10. Click the Save button.

  11. Go back to the spreadsheet.

  12. To test, select a value from the dropdown and wait a bit. The A1 will show the selected value, and a few seconds later, the value will be replaced with the calculated value. A1 will row a red triangle in the upper right corner because the entered value is invalid, unless it matches a value among the dropdown options.

Once you have a clear understanding on how this works, adapt it to meet your needs.

3
  • Ah, okay, great! I will give this an attempt and see if that works for me, thank you! Commented Mar 25 at 18:42
  • Looks like this is pretty close to what I want, but is there a way to add the two values instead of multiplying them? I tried replacing the * modifier with a +, but that just put them next to each other, i.e. A1 says 2 and B1 says 3, A1 gets updated to 32 Commented Mar 25 at 18:55
  • 1
    Made a followup post @webapps.stackexchange.com/questions/181029/… Commented Mar 25 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.