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 Answer
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.
Create a new spreadsheet
On A1, insert a dropdown. The Data Validation will be opened.
Replace the default values for the options with numbers
Click Advanced, and in the section If data is invalid, select Show a warning.
Click Done and close the Data Validations side panel.
On B1, add the number to us to multiply the selected value.
Click Extensions > Apps Script.
Set the Apps Script project title.
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); }Click the Save button.
Go back to the spreadsheet.
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.
-
Ah, okay, great! I will give this an attempt and see if that works for me, thank you!Kate Wilde– Kate Wilde2025-03-25 18:42:27 +00:00Commented 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 32Kate Wilde– Kate Wilde2025-03-25 18:55:15 +00:00Commented Mar 25 at 18:55
-
1Made a followup post @webapps.stackexchange.com/questions/181029/…Kate Wilde– Kate Wilde2025-03-25 23:57:08 +00:00Commented Mar 25 at 23:57