Last active
May 7, 2020 08:57
-
-
Save JustinByrne/c265ddd4a3e4cf90a2a1be6b822abfa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get column by the content in it - first row only | |
function getColByName(columnName) { | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getSheets()[0]; | |
var range = sheet.getRange(1, 1, 1, sheet.getLastColumn()); | |
var values = range.getValues(); | |
for (var row in values) { | |
for (var col in values[row]) { | |
if (values[row][col] == columnName) { | |
var num = Number(col) + 1; | |
return num.toFixed(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment