I'm working on a small project for myself in Google Sheets.
I need to get a cell name (ex. "A2") by searching for a word in a specified row (ex. search for a specific date in row 3).
After getting the cell coordinates, I have to write a text in 2 columns down the cell I found (if I find "A2" has the text I am searching for in it, cell "A4" will be set to a value I want
(all of that after pressing a button with a script assigned, it's important, the function is already linked to the button)
I'm trying to do something like this:
Before clicking the blue button
You may use this sample script as a reference for what you would like to do:
I have also added some explanations of what the code does
function myFunction() {
// Gets your current active sheet
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Gets the value of the "F3" cell
var currentDayCell = ss.getRange("F3").getValue();
// Row 8
var row = 8;
// Column C
var column = 3;
// The number of rows to return
var numRows = 1;
// The number of columns to return
var numCol = ss.getLastColumn();
// Gets the values of the data range
var values = ss.getRange(row, column, numRows, numCol).getValues();
// Iterates over the "values" and checks if the current value is equal to the cell of "F3". Also logs "💧" two cells down on the value where it's the same in "F3"
values.map(x => x.map((y, i) => y.toString() == currentDayCell.toString() ? ss.getRange(row + 2, column + i).setValue("💧") : x));
}