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













0















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:



  1. Two sheets, one Activity and another $SheetData.

  2. Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.

  3. The data for Column E is sourced from sheet $SheetData (E1:K1);

  4. The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);

  5. 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
Activity sheet



$SheetData
Data sheet










share|improve this question
























  • 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















0















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:



  1. Two sheets, one Activity and another $SheetData.

  2. Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.

  3. The data for Column E is sourced from sheet $SheetData (E1:K1);

  4. The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);

  5. 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
Activity sheet



$SheetData
Data sheet










share|improve this question
























  • 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













0












0








0








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:



  1. Two sheets, one Activity and another $SheetData.

  2. Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.

  3. The data for Column E is sourced from sheet $SheetData (E1:K1);

  4. The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);

  5. 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
Activity sheet



$SheetData
Data sheet










share|improve this question
















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:



  1. Two sheets, one Activity and another $SheetData.

  2. Column E of the Activity contains dropdowns, which when selected, should provide appropriate choice in the column G.

  3. The data for Column E is sourced from sheet $SheetData (E1:K1);

  4. The data for Column G is sourced from sheet $SheetData from each of the respective columns (E1 = SIRE: SIRE1, SIRE2 etc);

  5. 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
Activity sheet



$SheetData
Data sheet







google-apps-script drop-down-menu google-sheets






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 14:44







AlexShevyakov

















asked Mar 21 at 13:45









AlexShevyakovAlexShevyakov

136314




136314












  • 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

















  • 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
















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












1 Answer
1






active

oldest

votes


















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.






share|improve this answer























  • Thank you! Of course, how could I missed that apparent bloomer!

    – AlexShevyakov
    Mar 21 at 19:22










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
);



);













draft saved

draft discarded


















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









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.






share|improve this answer























  • Thank you! Of course, how could I missed that apparent bloomer!

    – AlexShevyakov
    Mar 21 at 19:22















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.






share|improve this answer























  • Thank you! Of course, how could I missed that apparent bloomer!

    – AlexShevyakov
    Mar 21 at 19:22













1












1








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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현