Dependable dropdown and getValues() 2D arrayHow to make Twitter Bootstrap menu dropdown on hover rather than clickAvoid dropdown menu close on click insideGoogle Script: InputBox with drop down list spreadsheet (Not FORM)Google Sheets: How to appendRow with 2d getValues array?Script to automatically capitalize contents of a cell in Google Sheets?Sheets script: button activated, copies data from a cell to sheet, then clears range of dataGoogle Sheets - Script Slow - Dependent DropdowngetValue / setValue multiple cellsPopulating multi-dimensional array using getValuesGoogle Apps Script, SpreadsheetApp.getActiveSheet().getActiveCell().getValue() changes return values when Filter view with sort applied
What is this type of notehead called?
Why is Arduino resetting while driving motors?
We have a love-hate relationship
How do ground effect vehicles perform turns?
Can somebody explain Brexit in a few child-proof sentences?
What does this horizontal bar at the first measure mean?
Using a siddur to Daven from in a seforim store
Create all possible words using a set or letters
Frequency of inspection at vegan restaurants
API Access HTML/Javascript
Are lightweight LN wallets vulnerable to transaction withholding?
Could solar power be utilized and substitute coal in the 19th Century
Reply 'no position' while the job posting is still there
Difference between -| and |- in TikZ
Why do IPv6 unique local addresses have to have a /48 prefix?
How will losing mobility of one hand affect my career as a programmer?
How do I extrude a face to a single vertex
Customize circled numbers
If a character with the Alert feat rolls a crit fail on their Perception check, are they surprised?
Indicating multiple different modes of speech (fantasy language or telepathy)
How should I respond when I lied about my education and the company finds out through background check?
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
Visiting the UK as unmarried couple
How to align and center standalone amsmath equations?
Dependable dropdown and getValues() 2D array
How to make Twitter Bootstrap menu dropdown on hover rather than clickAvoid dropdown menu close on click insideGoogle Script: InputBox with drop down list spreadsheet (Not FORM)Google Sheets: How to appendRow with 2d getValues array?Script to automatically capitalize contents of a cell in Google Sheets?Sheets script: button activated, copies data from a cell to sheet, then clears range of dataGoogle Sheets - Script Slow - Dependent DropdowngetValue / setValue multiple cellsPopulating multi-dimensional array using getValuesGoogle Apps Script, SpreadsheetApp.getActiveSheet().getActiveCell().getValue() changes return values when Filter view with sort applied
I am building dependable (filtered) dropdown in google sheet, where value in the one dropdown list depends on the choice of another. Although being a releatively simple arrangement, I came across the problem with getValues()
which returns 2D array.
There is the following set up:
- Two sheets, one Activity and another $SheetData.
- Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.
- The data for Column E is sourced from sheet $SheetData (E1:K1);
- The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);
- When SIRE is selected in Col E of Activity, I need the data in column G to be from E2:E of the $SheetData
Here is my code:
function dependableDropdown()
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activity = ss.getSheetByName("Activity");
var sheetData = ss.getSheetByName("$SheetData");
var activeCell = activity.getActiveCell();
if(activeCell.getColumn() == 5 && activeCell.getRow() > 1)
activeCell.offset(0, 2).clearContent().clearDataValidations();
var inspectionTypes = sheetData.getRange(1, 5, 1, 7).getValues();
var selectedValue = activeCell.getValue();
var inspectionTypesIndex = inspectionTypes[0].indexOf(selectedValue) + 1;
var validationRange = sheetData.getRange(2, inspectionTypesIndex, sheetData.getLastRow());
var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
activeCell.offset(0, 2).setDataValidation(validationRule);
;
;
Value returned by inspectionTypesIndex
seems to be correct (SIRE = 1, OVID = 2 etc), but when I select data in Col E, I get the wrong data fed into the column G.
Apprecaite your help.
Thank you,
Corresponding screens:
Activity sheet
$SheetData
google-apps-script drop-down-menu google-sheets
add a comment |
I am building dependable (filtered) dropdown in google sheet, where value in the one dropdown list depends on the choice of another. Although being a releatively simple arrangement, I came across the problem with getValues()
which returns 2D array.
There is the following set up:
- Two sheets, one Activity and another $SheetData.
- Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.
- The data for Column E is sourced from sheet $SheetData (E1:K1);
- The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);
- When SIRE is selected in Col E of Activity, I need the data in column G to be from E2:E of the $SheetData
Here is my code:
function dependableDropdown()
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activity = ss.getSheetByName("Activity");
var sheetData = ss.getSheetByName("$SheetData");
var activeCell = activity.getActiveCell();
if(activeCell.getColumn() == 5 && activeCell.getRow() > 1)
activeCell.offset(0, 2).clearContent().clearDataValidations();
var inspectionTypes = sheetData.getRange(1, 5, 1, 7).getValues();
var selectedValue = activeCell.getValue();
var inspectionTypesIndex = inspectionTypes[0].indexOf(selectedValue) + 1;
var validationRange = sheetData.getRange(2, inspectionTypesIndex, sheetData.getLastRow());
var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
activeCell.offset(0, 2).setDataValidation(validationRule);
;
;
Value returned by inspectionTypesIndex
seems to be correct (SIRE = 1, OVID = 2 etc), but when I select data in Col E, I get the wrong data fed into the column G.
Apprecaite your help.
Thank you,
Corresponding screens:
Activity sheet
$SheetData
google-apps-script drop-down-menu google-sheets
How do you trigger the above functiondependableDropdown()
? Or do you run it manually as preliminary test?
– Александр Ермолин
Mar 21 at 18:00
@АлександрЕрмолин there is onEdit() down below where dependableDropdown() is called.
– AlexShevyakov
Mar 21 at 19:04
add a comment |
I am building dependable (filtered) dropdown in google sheet, where value in the one dropdown list depends on the choice of another. Although being a releatively simple arrangement, I came across the problem with getValues()
which returns 2D array.
There is the following set up:
- Two sheets, one Activity and another $SheetData.
- Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.
- The data for Column E is sourced from sheet $SheetData (E1:K1);
- The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);
- When SIRE is selected in Col E of Activity, I need the data in column G to be from E2:E of the $SheetData
Here is my code:
function dependableDropdown()
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activity = ss.getSheetByName("Activity");
var sheetData = ss.getSheetByName("$SheetData");
var activeCell = activity.getActiveCell();
if(activeCell.getColumn() == 5 && activeCell.getRow() > 1)
activeCell.offset(0, 2).clearContent().clearDataValidations();
var inspectionTypes = sheetData.getRange(1, 5, 1, 7).getValues();
var selectedValue = activeCell.getValue();
var inspectionTypesIndex = inspectionTypes[0].indexOf(selectedValue) + 1;
var validationRange = sheetData.getRange(2, inspectionTypesIndex, sheetData.getLastRow());
var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
activeCell.offset(0, 2).setDataValidation(validationRule);
;
;
Value returned by inspectionTypesIndex
seems to be correct (SIRE = 1, OVID = 2 etc), but when I select data in Col E, I get the wrong data fed into the column G.
Apprecaite your help.
Thank you,
Corresponding screens:
Activity sheet
$SheetData
google-apps-script drop-down-menu google-sheets
I am building dependable (filtered) dropdown in google sheet, where value in the one dropdown list depends on the choice of another. Although being a releatively simple arrangement, I came across the problem with getValues()
which returns 2D array.
There is the following set up:
- Two sheets, one Activity and another $SheetData.
- Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.
- The data for Column E is sourced from sheet $SheetData (E1:K1);
- The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);
- When SIRE is selected in Col E of Activity, I need the data in column G to be from E2:E of the $SheetData
Here is my code:
function dependableDropdown()
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activity = ss.getSheetByName("Activity");
var sheetData = ss.getSheetByName("$SheetData");
var activeCell = activity.getActiveCell();
if(activeCell.getColumn() == 5 && activeCell.getRow() > 1)
activeCell.offset(0, 2).clearContent().clearDataValidations();
var inspectionTypes = sheetData.getRange(1, 5, 1, 7).getValues();
var selectedValue = activeCell.getValue();
var inspectionTypesIndex = inspectionTypes[0].indexOf(selectedValue) + 1;
var validationRange = sheetData.getRange(2, inspectionTypesIndex, sheetData.getLastRow());
var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
activeCell.offset(0, 2).setDataValidation(validationRule);
;
;
Value returned by inspectionTypesIndex
seems to be correct (SIRE = 1, OVID = 2 etc), but when I select data in Col E, I get the wrong data fed into the column G.
Apprecaite your help.
Thank you,
Corresponding screens:
Activity sheet
$SheetData
google-apps-script drop-down-menu google-sheets
google-apps-script drop-down-menu google-sheets
edited Mar 21 at 14:44
AlexShevyakov
asked Mar 21 at 13:45
AlexShevyakovAlexShevyakov
136314
136314
How do you trigger the above functiondependableDropdown()
? Or do you run it manually as preliminary test?
– Александр Ермолин
Mar 21 at 18:00
@АлександрЕрмолин there is onEdit() down below where dependableDropdown() is called.
– AlexShevyakov
Mar 21 at 19:04
add a comment |
How do you trigger the above functiondependableDropdown()
? Or do you run it manually as preliminary test?
– Александр Ермолин
Mar 21 at 18:00
@АлександрЕрмолин there is onEdit() down below where dependableDropdown() is called.
– AlexShevyakov
Mar 21 at 19:04
How do you trigger the above function
dependableDropdown()
? Or do you run it manually as preliminary test?– Александр Ермолин
Mar 21 at 18:00
How do you trigger the above function
dependableDropdown()
? Or do you run it manually as preliminary test?– Александр Ермолин
Mar 21 at 18:00
@АлександрЕрмолин there is onEdit() down below where dependableDropdown() is called.
– AlexShevyakov
Mar 21 at 19:04
@АлександрЕрмолин there is onEdit() down below where dependableDropdown() is called.
– AlexShevyakov
Mar 21 at 19:04
add a comment |
1 Answer
1
active
oldest
votes
If you get inspectionTypesIndex
as written (SIRE = 1, OVID = 2 etc), and you have options columns: E, F, G, ... , then you should reference validationRange
in the following way:
var validationRange = sheetData.getRange(2, inspectionTypesIndex + 4, sheetData.getLastRow());
because E column is 5-th, but "SIRE" index is equal to 1.
Thank you! Of course, how could I missed that apparent bloomer!
– AlexShevyakov
Mar 21 at 19:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281860%2fdependable-dropdown-and-getvalues-2d-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you get inspectionTypesIndex
as written (SIRE = 1, OVID = 2 etc), and you have options columns: E, F, G, ... , then you should reference validationRange
in the following way:
var validationRange = sheetData.getRange(2, inspectionTypesIndex + 4, sheetData.getLastRow());
because E column is 5-th, but "SIRE" index is equal to 1.
Thank you! Of course, how could I missed that apparent bloomer!
– AlexShevyakov
Mar 21 at 19:22
add a comment |
If you get inspectionTypesIndex
as written (SIRE = 1, OVID = 2 etc), and you have options columns: E, F, G, ... , then you should reference validationRange
in the following way:
var validationRange = sheetData.getRange(2, inspectionTypesIndex + 4, sheetData.getLastRow());
because E column is 5-th, but "SIRE" index is equal to 1.
Thank you! Of course, how could I missed that apparent bloomer!
– AlexShevyakov
Mar 21 at 19:22
add a comment |
If you get inspectionTypesIndex
as written (SIRE = 1, OVID = 2 etc), and you have options columns: E, F, G, ... , then you should reference validationRange
in the following way:
var validationRange = sheetData.getRange(2, inspectionTypesIndex + 4, sheetData.getLastRow());
because E column is 5-th, but "SIRE" index is equal to 1.
If you get inspectionTypesIndex
as written (SIRE = 1, OVID = 2 etc), and you have options columns: E, F, G, ... , then you should reference validationRange
in the following way:
var validationRange = sheetData.getRange(2, inspectionTypesIndex + 4, sheetData.getLastRow());
because E column is 5-th, but "SIRE" index is equal to 1.
answered Mar 21 at 18:13
Александр ЕрмолинАлександр Ермолин
51626
51626
Thank you! Of course, how could I missed that apparent bloomer!
– AlexShevyakov
Mar 21 at 19:22
add a comment |
Thank you! Of course, how could I missed that apparent bloomer!
– AlexShevyakov
Mar 21 at 19:22
Thank you! Of course, how could I missed that apparent bloomer!
– AlexShevyakov
Mar 21 at 19:22
Thank you! Of course, how could I missed that apparent bloomer!
– AlexShevyakov
Mar 21 at 19:22
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281860%2fdependable-dropdown-and-getvalues-2d-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How do you trigger the above function
dependableDropdown()
? Or do you run it manually as preliminary test?– Александр Ермолин
Mar 21 at 18:00
@АлександрЕрмолин there is onEdit() down below where dependableDropdown() is called.
– AlexShevyakov
Mar 21 at 19:04