Google scripts - issue with string vs cell as function parameterGoogle Script: InputBox with drop down list spreadsheet (Not FORM)Retrieve row from a table (with a specific value) and insert specific row to a new sheetGAS - Checking edited cellCompare dates in Google Sheets using Apps ScriptGoogle Scripts Search & Return Cell LocationFastest way to populate an arrays from spreadsheet columnsHow to find the row index of a specific string within an arrayGoogle Sheets Script setformula for LoopHow can I get sheet range(s) from a list of individual cell row and column positions?Pass a Spreadsheet Url cell to the src Google Spreadsheet & Google Docs
What exactly is ineptocracy?
how do we prove that a sum of two periods is still a period?
What do you call someone who asks many questions?
Sums of two squares in arithmetic progressions
How can I prove that a state of equilibrium is unstable?
What would the climate of a planetwide city be like?
In Bayesian inference, why are some terms dropped from the posterior predictive?
How could indestructible materials be used in power generation?
How does a dynamic QR code work?
Avoiding the "not like other girls" trope?
Rotate ASCII Art by 45 Degrees
Pact of Blade Warlock with Dancing Blade
Can I hook these wires up to find the connection to a dead outlet?
Processor speed limited at 0.4 Ghz
What is the most common color to indicate the input-field is disabled?
How seriously should I take size and weight limits of hand luggage?
Where would I need my direct neural interface to be implanted?
How to install cross-compiler on Ubuntu 18.04?
What does the same-ish mean?
Did 'Cinema Songs' exist during Hiranyakshipu's time?
Do creatures with a speed 0ft., fly 30ft. (hover) ever touch the ground?
How obscure is the use of 令 in 令和?
OP Amp not amplifying audio signal
Should I tell management that I intend to leave due to bad software development practices?
Google scripts - issue with string vs cell as function parameter
Google Script: InputBox with drop down list spreadsheet (Not FORM)Retrieve row from a table (with a specific value) and insert specific row to a new sheetGAS - Checking edited cellCompare dates in Google Sheets using Apps ScriptGoogle Scripts Search & Return Cell LocationFastest way to populate an arrays from spreadsheet columnsHow to find the row index of a specific string within an arrayGoogle Sheets Script setformula for LoopHow can I get sheet range(s) from a list of individual cell row and column positions?Pass a Spreadsheet Url cell to the src Google Spreadsheet & Google Docs
I'm learning Google script as I go along and came across an issue that I could not find a solution for.
I have a function that takes in several several strings and one cell as params.
I assume passing a cell is not same as passing its value (string too btw)
Please find attached code:
//return id assigned to data(cell) sheetname
function findInColumn(column, data, colName, sheetname)
/*
data = cell (cell value is 'bag_backpack.png') does not work
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
data = 'bag_backpack.png'; <---works
*/
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetname);
var column = sheet.getRange(column + ":" + column); // like A:A
var values = [];
for (var index = 0; index < column.getValues().length; index++)
values.push(column.getValues()[index][0])
var colIndex = getByName(colName, sheetname);
var rowIndex = values.indexOf(data);
//grab id value of data
var range = sheet.getRange(rowIndex+1,colIndex+1);
var data = range.getValue();
return data
While I value and need your feedback I kindly request your bear in mind I'm a novice at best and I've spend several hours searching before asking here.
Thank you for your help.
Edit: bag_backpack.png is the content of a cell I'm searching in a column to get the row number of said cell.
var rowIndex = values.indexOf(data);
Returns the index I need.
However... if I feed a cell to the function instead of a string like a cell elsewhere with bag_backpack.png as its content or even derive said value from it:
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
In said case:
var rowIndex = values.indexOf(data);
gives out -1 instead of index desired.
google-apps-script
add a comment |
I'm learning Google script as I go along and came across an issue that I could not find a solution for.
I have a function that takes in several several strings and one cell as params.
I assume passing a cell is not same as passing its value (string too btw)
Please find attached code:
//return id assigned to data(cell) sheetname
function findInColumn(column, data, colName, sheetname)
/*
data = cell (cell value is 'bag_backpack.png') does not work
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
data = 'bag_backpack.png'; <---works
*/
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetname);
var column = sheet.getRange(column + ":" + column); // like A:A
var values = [];
for (var index = 0; index < column.getValues().length; index++)
values.push(column.getValues()[index][0])
var colIndex = getByName(colName, sheetname);
var rowIndex = values.indexOf(data);
//grab id value of data
var range = sheet.getRange(rowIndex+1,colIndex+1);
var data = range.getValue();
return data
While I value and need your feedback I kindly request your bear in mind I'm a novice at best and I've spend several hours searching before asking here.
Thank you for your help.
Edit: bag_backpack.png is the content of a cell I'm searching in a column to get the row number of said cell.
var rowIndex = values.indexOf(data);
Returns the index I need.
However... if I feed a cell to the function instead of a string like a cell elsewhere with bag_backpack.png as its content or even derive said value from it:
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
In said case:
var rowIndex = values.indexOf(data);
gives out -1 instead of index desired.
google-apps-script
In order to correctly understand your question, can I ask you about your issue? 1. How do you want to use the function? You run it from the script editor or as a custom function? 2. AboutI assume passing a cell is not same as passing its value (string too btw), can you explain about this? 3. What is the commented script in your script?
– Tanaike
Mar 7 at 22:28
2
What is it that you're trying to accomplish? Try and get your code to a bare minimum set that reproduces your problem and state clearly what is the result you' re getting vs what is it that you expect (please edit your question, do not address this by replying in the comment's section).
– Henrique G. Abreu
Mar 7 at 22:40
@HenriqueG.Abreu
– Avi E. Koenig
Mar 7 at 23:18
add a comment |
I'm learning Google script as I go along and came across an issue that I could not find a solution for.
I have a function that takes in several several strings and one cell as params.
I assume passing a cell is not same as passing its value (string too btw)
Please find attached code:
//return id assigned to data(cell) sheetname
function findInColumn(column, data, colName, sheetname)
/*
data = cell (cell value is 'bag_backpack.png') does not work
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
data = 'bag_backpack.png'; <---works
*/
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetname);
var column = sheet.getRange(column + ":" + column); // like A:A
var values = [];
for (var index = 0; index < column.getValues().length; index++)
values.push(column.getValues()[index][0])
var colIndex = getByName(colName, sheetname);
var rowIndex = values.indexOf(data);
//grab id value of data
var range = sheet.getRange(rowIndex+1,colIndex+1);
var data = range.getValue();
return data
While I value and need your feedback I kindly request your bear in mind I'm a novice at best and I've spend several hours searching before asking here.
Thank you for your help.
Edit: bag_backpack.png is the content of a cell I'm searching in a column to get the row number of said cell.
var rowIndex = values.indexOf(data);
Returns the index I need.
However... if I feed a cell to the function instead of a string like a cell elsewhere with bag_backpack.png as its content or even derive said value from it:
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
In said case:
var rowIndex = values.indexOf(data);
gives out -1 instead of index desired.
google-apps-script
I'm learning Google script as I go along and came across an issue that I could not find a solution for.
I have a function that takes in several several strings and one cell as params.
I assume passing a cell is not same as passing its value (string too btw)
Please find attached code:
//return id assigned to data(cell) sheetname
function findInColumn(column, data, colName, sheetname)
/*
data = cell (cell value is 'bag_backpack.png') does not work
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
data = 'bag_backpack.png'; <---works
*/
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetname);
var column = sheet.getRange(column + ":" + column); // like A:A
var values = [];
for (var index = 0; index < column.getValues().length; index++)
values.push(column.getValues()[index][0])
var colIndex = getByName(colName, sheetname);
var rowIndex = values.indexOf(data);
//grab id value of data
var range = sheet.getRange(rowIndex+1,colIndex+1);
var data = range.getValue();
return data
While I value and need your feedback I kindly request your bear in mind I'm a novice at best and I've spend several hours searching before asking here.
Thank you for your help.
Edit: bag_backpack.png is the content of a cell I'm searching in a column to get the row number of said cell.
var rowIndex = values.indexOf(data);
Returns the index I need.
However... if I feed a cell to the function instead of a string like a cell elsewhere with bag_backpack.png as its content or even derive said value from it:
var range = SpreadsheetApp.getActiveRange();
var col = range.getColumn();
var row = range.getRow();
var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
data = range2.getValue(); (cell value is 'bag_backpack.png') <---fail too
In said case:
var rowIndex = values.indexOf(data);
gives out -1 instead of index desired.
google-apps-script
google-apps-script
edited Mar 8 at 6:41
Tiw
4,35461630
4,35461630
asked Mar 7 at 21:00
Avi E. KoenigAvi E. Koenig
368
368
In order to correctly understand your question, can I ask you about your issue? 1. How do you want to use the function? You run it from the script editor or as a custom function? 2. AboutI assume passing a cell is not same as passing its value (string too btw), can you explain about this? 3. What is the commented script in your script?
– Tanaike
Mar 7 at 22:28
2
What is it that you're trying to accomplish? Try and get your code to a bare minimum set that reproduces your problem and state clearly what is the result you' re getting vs what is it that you expect (please edit your question, do not address this by replying in the comment's section).
– Henrique G. Abreu
Mar 7 at 22:40
@HenriqueG.Abreu
– Avi E. Koenig
Mar 7 at 23:18
add a comment |
In order to correctly understand your question, can I ask you about your issue? 1. How do you want to use the function? You run it from the script editor or as a custom function? 2. AboutI assume passing a cell is not same as passing its value (string too btw), can you explain about this? 3. What is the commented script in your script?
– Tanaike
Mar 7 at 22:28
2
What is it that you're trying to accomplish? Try and get your code to a bare minimum set that reproduces your problem and state clearly what is the result you' re getting vs what is it that you expect (please edit your question, do not address this by replying in the comment's section).
– Henrique G. Abreu
Mar 7 at 22:40
@HenriqueG.Abreu
– Avi E. Koenig
Mar 7 at 23:18
In order to correctly understand your question, can I ask you about your issue? 1. How do you want to use the function? You run it from the script editor or as a custom function? 2. About
I assume passing a cell is not same as passing its value (string too btw), can you explain about this? 3. What is the commented script in your script?– Tanaike
Mar 7 at 22:28
In order to correctly understand your question, can I ask you about your issue? 1. How do you want to use the function? You run it from the script editor or as a custom function? 2. About
I assume passing a cell is not same as passing its value (string too btw), can you explain about this? 3. What is the commented script in your script?– Tanaike
Mar 7 at 22:28
2
2
What is it that you're trying to accomplish? Try and get your code to a bare minimum set that reproduces your problem and state clearly what is the result you' re getting vs what is it that you expect (please edit your question, do not address this by replying in the comment's section).
– Henrique G. Abreu
Mar 7 at 22:40
What is it that you're trying to accomplish? Try and get your code to a bare minimum set that reproduces your problem and state clearly what is the result you' re getting vs what is it that you expect (please edit your question, do not address this by replying in the comment's section).
– Henrique G. Abreu
Mar 7 at 22:40
@HenriqueG.Abreu
– Avi E. Koenig
Mar 7 at 23:18
@HenriqueG.Abreu
– Avi E. Koenig
Mar 7 at 23:18
add a comment |
2 Answers
2
active
oldest
votes
Most of what you have doesn't make sense to me. I'm guessing that this is what you want. Since I can't figure out what you want, perhaps you can tell me what I missed.
function findInColumn(column,sheetname)
var sh=SpreadsheetApp.getActive().getSheetByName(sheetname);
var rg=sh.getRange(column + ":" + column); /
var vA=rg.getValues();
var values = [];
for (var i=0;i<vA.length; i++)
values.push(vA[i][0]);
return values
Thank you for your help! I used the function since it helped me make the code a bit more modular. But my issue was a typo in the end :'(
– Avi E. Koenig
Mar 8 at 0:43
add a comment |
I want to thank everyone for taking the time to reply.
the issue was NOT with the code but with some of the first filename having uppercase in the id,name sheet while the binder sheet it did not.(at least 5 hours on Tent.png/tent.png)
I'm attaching a link to my finished work in hopes it benefits anyone.
https://docs.google.com/spreadsheets/d/1jCy1I4r6PeY3kUWrhNno2XO18Jghq6_b1kyN3AflidM/edit?usp=sharing
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%2f55052712%2fgoogle-scripts-issue-with-string-vs-cell-as-function-parameter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Most of what you have doesn't make sense to me. I'm guessing that this is what you want. Since I can't figure out what you want, perhaps you can tell me what I missed.
function findInColumn(column,sheetname)
var sh=SpreadsheetApp.getActive().getSheetByName(sheetname);
var rg=sh.getRange(column + ":" + column); /
var vA=rg.getValues();
var values = [];
for (var i=0;i<vA.length; i++)
values.push(vA[i][0]);
return values
Thank you for your help! I used the function since it helped me make the code a bit more modular. But my issue was a typo in the end :'(
– Avi E. Koenig
Mar 8 at 0:43
add a comment |
Most of what you have doesn't make sense to me. I'm guessing that this is what you want. Since I can't figure out what you want, perhaps you can tell me what I missed.
function findInColumn(column,sheetname)
var sh=SpreadsheetApp.getActive().getSheetByName(sheetname);
var rg=sh.getRange(column + ":" + column); /
var vA=rg.getValues();
var values = [];
for (var i=0;i<vA.length; i++)
values.push(vA[i][0]);
return values
Thank you for your help! I used the function since it helped me make the code a bit more modular. But my issue was a typo in the end :'(
– Avi E. Koenig
Mar 8 at 0:43
add a comment |
Most of what you have doesn't make sense to me. I'm guessing that this is what you want. Since I can't figure out what you want, perhaps you can tell me what I missed.
function findInColumn(column,sheetname)
var sh=SpreadsheetApp.getActive().getSheetByName(sheetname);
var rg=sh.getRange(column + ":" + column); /
var vA=rg.getValues();
var values = [];
for (var i=0;i<vA.length; i++)
values.push(vA[i][0]);
return values
Most of what you have doesn't make sense to me. I'm guessing that this is what you want. Since I can't figure out what you want, perhaps you can tell me what I missed.
function findInColumn(column,sheetname)
var sh=SpreadsheetApp.getActive().getSheetByName(sheetname);
var rg=sh.getRange(column + ":" + column); /
var vA=rg.getValues();
var values = [];
for (var i=0;i<vA.length; i++)
values.push(vA[i][0]);
return values
answered Mar 7 at 23:33
CooperCooper
8,2142829
8,2142829
Thank you for your help! I used the function since it helped me make the code a bit more modular. But my issue was a typo in the end :'(
– Avi E. Koenig
Mar 8 at 0:43
add a comment |
Thank you for your help! I used the function since it helped me make the code a bit more modular. But my issue was a typo in the end :'(
– Avi E. Koenig
Mar 8 at 0:43
Thank you for your help! I used the function since it helped me make the code a bit more modular. But my issue was a typo in the end :'(
– Avi E. Koenig
Mar 8 at 0:43
Thank you for your help! I used the function since it helped me make the code a bit more modular. But my issue was a typo in the end :'(
– Avi E. Koenig
Mar 8 at 0:43
add a comment |
I want to thank everyone for taking the time to reply.
the issue was NOT with the code but with some of the first filename having uppercase in the id,name sheet while the binder sheet it did not.(at least 5 hours on Tent.png/tent.png)
I'm attaching a link to my finished work in hopes it benefits anyone.
https://docs.google.com/spreadsheets/d/1jCy1I4r6PeY3kUWrhNno2XO18Jghq6_b1kyN3AflidM/edit?usp=sharing
add a comment |
I want to thank everyone for taking the time to reply.
the issue was NOT with the code but with some of the first filename having uppercase in the id,name sheet while the binder sheet it did not.(at least 5 hours on Tent.png/tent.png)
I'm attaching a link to my finished work in hopes it benefits anyone.
https://docs.google.com/spreadsheets/d/1jCy1I4r6PeY3kUWrhNno2XO18Jghq6_b1kyN3AflidM/edit?usp=sharing
add a comment |
I want to thank everyone for taking the time to reply.
the issue was NOT with the code but with some of the first filename having uppercase in the id,name sheet while the binder sheet it did not.(at least 5 hours on Tent.png/tent.png)
I'm attaching a link to my finished work in hopes it benefits anyone.
https://docs.google.com/spreadsheets/d/1jCy1I4r6PeY3kUWrhNno2XO18Jghq6_b1kyN3AflidM/edit?usp=sharing
I want to thank everyone for taking the time to reply.
the issue was NOT with the code but with some of the first filename having uppercase in the id,name sheet while the binder sheet it did not.(at least 5 hours on Tent.png/tent.png)
I'm attaching a link to my finished work in hopes it benefits anyone.
https://docs.google.com/spreadsheets/d/1jCy1I4r6PeY3kUWrhNno2XO18Jghq6_b1kyN3AflidM/edit?usp=sharing
edited Mar 8 at 2:23
Cooper
8,2142829
8,2142829
answered Mar 8 at 0:41
Avi E. KoenigAvi E. Koenig
368
368
add a comment |
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%2f55052712%2fgoogle-scripts-issue-with-string-vs-cell-as-function-parameter%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
In order to correctly understand your question, can I ask you about your issue? 1. How do you want to use the function? You run it from the script editor or as a custom function? 2. About
I assume passing a cell is not same as passing its value (string too btw), can you explain about this? 3. What is the commented script in your script?– Tanaike
Mar 7 at 22:28
2
What is it that you're trying to accomplish? Try and get your code to a bare minimum set that reproduces your problem and state clearly what is the result you' re getting vs what is it that you expect (please edit your question, do not address this by replying in the comment's section).
– Henrique G. Abreu
Mar 7 at 22:40
@HenriqueG.Abreu
– Avi E. Koenig
Mar 7 at 23:18