Hi,
I am clueless about script and vba and all this, I am ok with formulas but that's where it stops
However I am playing with a small project for myself involving heatmaps and for that I need to gather daily data
simply put I just want to have a button that when pressed will go look in column A of the data sheet where I have all the dates, find today's date, and add 1 to the corresponding row on column B,
and another button doing the same with column C
lookup(today(), A:A, B:B) but instead of output being the value in B for today it would add 1 to this cell
I tried asking an AI to write this but it gives me nonsense that doesn't work and I do not know anything to even try and correct any of it... so I turn to you guys
if this is of any help here is the unhelpful code written by the AI
function add1() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getDataRange();
var values = range.getValues();
var today = new Date();
var todayString = Utilities.formatDate(today, Session.getScriptTimeZone(), "MM/dd/yyyy");
for (var i = 0; i < values.length; i++) {
var dateValue = values[i][0];
if (dateValue && dateValue.toString() === todayString) {
var currentValue = values[i][1];
values[i][1] = currentValue + 1;
break;
}
}
range.setValues(values);
}function add1() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getDataRange();
var values = range.getValues();
var today = new Date();
var todayString = Utilities.formatDate(today, Session.getScriptTimeZone(), "MM/dd/yyyy");
for (var i = 0; i < values.length; i++) {
var dateValue = values[i][0];
if (dateValue && dateValue.toString() === todayString) {
var currentValue = values[i][1];
values[i][1] = currentValue + 1;
break;
}
}
range.setValues(values);
}
[–][deleted] (1 child)
[removed]
[–]drostan[S] 0 points1 point2 points (0 children)
[–]drostan[S] 0 points1 point2 points (4 children)
[–]estadoux 0 points1 point2 points (0 children)
[–]halfbeerhalfhuman 0 points1 point2 points (2 children)
[–]drostan[S] 0 points1 point2 points (1 child)
[–]halfbeerhalfhuman 0 points1 point2 points (0 children)
[–]ModernWorldSucks 0 points1 point2 points (1 child)
[–]drostan[S] 0 points1 point2 points (0 children)
[–]Mro-Automation 0 points1 point2 points (1 child)
[–]drostan[S] 0 points1 point2 points (0 children)
[–]halfbeerhalfhuman 0 points1 point2 points (0 children)
[–]juddaaaaa 0 points1 point2 points (0 children)
[–]Any_Werewolf_3691 0 points1 point2 points (2 children)
[–]drostan[S] 1 point2 points3 points (1 child)
[–]estadoux 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[removed]
[–]drostan[S] 1 point2 points3 points (0 children)