I want to get a string value -to compare it later on with an if condition- from only one column in spreadsheet using Google apps script. I searched the internet and I found this link - sorry if this sounds stupid, I am new to Google apps scripts - https://developers.google.com/apps-script/class_spreadsheet
var values = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getValues();
I guess that must be helpful, the only problem is that the column I want to get the values from is dynamic so how do I set the range of this column
if you use simply :
var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues()
You will get a 2 Dimension array of all the data in the sheet indexed by rows and columns.
So to get the value in column A, row1 you use
values[0][0]
,values[1][0]
for columnA, row 2,values[0][2]
for column C row1, etc...If you need to iterate in a for loop (in a single column) :
If you need to iterate in a for loop (in a single row) :
Here is the script I use to get the values in a dynamic column:
I've never had to change which starting row based based on a dynamic changing starting point though. Would be interested in seeing how that would be done.
Here is a similar post. Another example here.
much easier way to loop through the rows and get a column value.. hope that helps