Dynamic Google Sheet calendar - google-apps-script

I'm looking for a way to create a dynamic calendar in Google Sheets. - I have the basics already made. But I'm wondering if there is a way for the contents of the cell for each day to be different depending on the month.
For example:
If I entered "test" in 04/02/23 when I use the dropdown to go to March, the 04/03/22 cell would be blank & I could enter different info relevant to that date. All the while "test" would remain in 04/02/23 cell.
I know you would be able to achieve this with IF statements, but I'm looking for a wat to do this without changing formula each time a different event is added to the calendar.
Here's what I currently have:
https://docs.google.com/spreadsheets/d/1X4fRhpBhdCjblKPUWcULZ0Rv6mlHTqWwU1Hfco0h7JA/edit?usp=sharing
Thanks for any help.

Related

Use button in Google Sheets to open the pre-filled Google Form from dynamic hyperlink

Issue:
I have a Google Form, let's call it "Stock". The form simply records new entries of stock into the Google Sheet "Stock Form Responses". In this sheet, there is a field called Stock Number which has to be unique. In order to cut out human error in the process of assigning a new stock number to the rows of data added through the form, I have created a very simple formula in a cell:
=max('Stock Form Responses'!B:B)+1
This does exactly what I need it to do, and tells me the latest stock number, and adds one to it, ready for the next addition via the form. I then use this code in another cell (G9 of the sheet called "Control"), to pass that number to the prefilled form link for my form, like this:
=concatenate("https://docs.google.com/forms/MYFORMLINK/viewform?usp=pp_url&entry.465281926=",D10)
This is where D10 from the Control sheet stores the previous calculation of what the next stock number should be.
All of this works great so far, and everything works fine.
Problem:
Google Sheets has this really annoying feature where you can't just click a link in the sheet, you have to hover over it and then click the attached link. It's frustrating, and I'm trying to simplify and clean up steps. I simply want to pass the URL stored in G9 to an action attached to a button, let's call it AddStock. How do I do this?
I've been trawling the internet for hours trying to work it out, and can't seem to figure it out myself (admittedly I have very limited coding understanding, but people keep talking about popup blockers, etc).

Google Sheets - Track Current Cell Selection?

How to Get the currently selected cell/range? was asked 3.5 years ago, but I'm hoping maybe some progress was made since then.
I'd like to make an interactive spreadsheet where there's a boolean grid that will display more information about the status of the currently selected cell in a static location, allowing users to quickly navigate using the arrow keys.
Referencing the previous instance of this question, I tried using the custom function below to get the cell address, although this isn't very dynamic.
function currentCell() {
return SpreadsheetApp.getActive().getActiveRange().getA1Notation();
}
When testing, this function returns the address of the cell the function is called from. I've tried pressing F5 while highlighting another cell and nothing happened. I've also dragged the formula across a selection and each cell only contains its own address (according to the documentation, it should contain the range).
I've also read Henrique's post on caching from 2012, and while I don't completely understand it, I get that we could not get scripts which update without edits being made or manual formula updates.
I would ideally like for the current cell to be tracked without any extra prompts from the user besides arrow key navigation or clicking to select a cell, but if pressing a non-altering key (like Enter) would allow for tracking, that would be fine. I also only need the selected cell, rather than a range, if that makes things easier.
Explicit Question: Is it possible to track the position of the currently selected cell in Google Sheets and store that position in a separate cell? If not, is there a way to do this without altering cell values?
EDIT: Adding an example for clarity. In this conceptual example, A2 =currentCell() as described above. If I were to hit the right arrow key, A2 would update to display I4, since it is now the current selection.
EDIT2: Jason Allshorn's response to Google app script monitor spreadsheet selected ranges appears to give a way of displaying the current selection (range) on the HTML input text. I'd like to do this, but store the value in a static cell on the sheet rather than input text. I'm new to scripting in Sheets and really only know what I've found for resolving this issue, so if I'm overlooking something, please let me know. I did look at Jason's example sheet and it wasn't clear to me what was actually happening there.
You will have to apply the technique suggested on How do I make a Sidebar display values from cells?. This consist on using using client-side code to constantly pulling values from the spreadsheet and then do the corresponding task.
One approach is to use a side-panel with an input field to set the cells to be tracked and another input field to set the destination cell.
You will have to use the onSelectionChange event in the app script to capture any selection change and then get the range name and put it in desired cell.
Something like the below:
function onSelectionChange(e) {
const range = e.range;
//Return in case of multi cell selection
if(range.getNumRows() !== 1 || range.getNumColumns() !== 1) return;
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("A2").setValue(range.getA1Notation());
}
You can see the official documentation here

Changing date range for chart based on selected dropdown value

I have a Google Spreadsheet like this with a chart and a dropdown menu. I would like the data range of that chart to update based on a value selected from a dropdown menu.
I thought I might be able to add a Google App Script to the dropdown menu, but I can't find a way to add such script to anything but a drawing. Can someone tell me how to achieve this? Or point me into the right direction (Doc link?) as I'm new to both Google Spreadsheets and App Scripts.
Update:
From the comments it seems using App Scripts onEdit trigger might work.
The idea would be
to trigger onEdit when the value from the dropdown cell changes
fetch the cell value to use as an argument for another function
that in turn alters the data range of a chart.
As far as I can see onEdit triggers with changes made to any cell. Is there a way to limit this trigger to specific cells/ranges?
If I were you, I would use your drop-down menu as reference in a Query(). Often, I'll use a Query() in a hidden section of columns on my sheet, and use that hidden section as the data range for my charts. For example, if your drop down was in A1 you could have in B1 a Query() that uses a cell reference to find your data, and then hide columns B through however many you need to display your data. Then you make your data range B1:D (or whatever the range actually ended up being). Your example sheet has been moved to your trash, but if you share a data set with me, I could show you a pertinent example. Here is a less than pertinent example Ta-Da. I know that it is probably too general to use for your specific case, but perhaps if we knew more we could point you to a more specific work-around.

Google Spreadsheet: Script to Change One Cell's Background Color when Another Cell Changes Text

I have a Google spreadsheet where I keep a list of tasks, and I constantly change the status from four variations. For the purpose of this questions lets just say the four statuses are "Done", "Not Done", "In progress", "Failed".
I want to write a script for the Google spreadsheet where when I change the status, the cell right next to it will display a specific color respective to the status of each task.
I have looked into a few of the previous example where they highlight the whole row, but I'm looking into how to highlight one specific cell.
This can be accomplished with conditional formatting directly in the spreadsheet.
Right click on the first cell you want to change the color and choose "Conditional Formatting"
In the drop-down choose Custom formula is... Then enter =(A2 = "Done"). Check background color select then select a color. The range should be auto filled.
A2 would be whatever your status cell is.
Repeat this for each status you have.
You then can "Highlight and Drag-Copy" the cell with the formatting and it will adjust the range for you.
I'm new here, so please forgive any breaches in forum etiquette, but another user posted a similar question recently, and user Zwisch answered it using a loop that I think might also be applicable to what you are trying to accomplish.
You can likely adapt his answer to your needs by adding another conditional statement to address your different statuses. I do not yet have enough expertise to provide you an exact adaptation however.
See Zwisch's answer to how to apply conditional formatting using code.

Google Sheets Displaying cell data in sidebar

I have a Google Sheet that I'm using as a timesheet. I'd like to use the sidebar to report contents of cells. In addition to the main timesheet, I have a sheet that is dedicated to keeping track of total hours and overtime.
I'm looking for a way to display cell values from my tracking sheet in the sidebar, and have it update values every time the spreadsheet is edited.
Despite looking for several days, I either can't find, or can't grasp how it's done.
Thank you in advance for your time.
Create an onEdit() simple trigger function that runs every time a cell is edited. The sidebar will probably need to be re-displayed every time there is an edit that you want updated in the sidebar. I don't know of anyway to pass data to the sidebar without re-displaying it. I hope I'm wrong. I haven't researched it, but I can't think how that would be done. You could update the spreadsheet from the sidebar with no problem. But I don't know how you'd update the sidebar from the spreadsheet without re-displaying the sidebar.