Google Sheets Displaying cell data in sidebar - google-apps-script

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.

Related

Dynamic Google Sheet calendar

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.

Google Sheets: Why can't I insert a link (to anything) in a cell containing a formula

In any Google Sheet, select a cell containing a formula, for example, =SUM(1,1). You'll see that both the Insert->Link menu
and the toolbar button for Insert Link (Ctrl + K) are disabled.
Why is that?
PS:
I've spent considerable time on Google, but I haven't found this issue mentioned anywhere.
This problem occurs irrespective of whether the formula has been manually typed in the cell or been populated through Apps Script.
This is intended behaviour
If you press Ctrl+K when a cell with a formula is highlighted you get the following message:
Not sure if this applies to you, but I solved my problem after coming here. I realized that where I was trying to change the links was actually an "importrange" of another file. So I have a daily sales ticker that feeds out to our salespeople, but I don't want them to "see" my live file and accidentally make changes. So I use "importrange" to show just one page of my big file to the salespeople and if they accidentally make a change, it doesn't affect my original formulas. I was trying to update the links on the "shared version". Once I went to my original file, I could update the links as expected. It was ODD though that I was able to delete the link on the shared page. Just couldn't edit it or create a new link there.

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 scripts unhideRows not working

I have a script for Google Sheets I am working on. I realize there are better ways to do what I am attempting (cough html/database cough), but I am required to make this spreadsheet work.
In short, I am trying to hide and unhide rows dynamically. There does not appear to be a way to get filters to update without redoing them, so I am attempting to use hideRows to hide them and unhideRows to reveal them as needed.
The hideRows command works below. The unhideRows command does not. At this time, they are literally this close together in the code. Originally, I was hiding on one sheet and unhiding on another, but set up like this to troubleshoot. There is no filtering on this sheet (because it didn't work, I turned it off). I tried setting the value in unhideRows directly to the value tested instead of a variable.
The row in question hides, but does not unhide.
I tried unhiding a different row just in case google was fumbling with hide this, unhide it back to back. I am not getting unhide to work.
{ //thisRow = the row number of a range, in this case 2 if output to screen
pImages.hideRows(thisRow);
pImages.unhideRows(thisRow);
}
Apparently, the answer is not to unhideRows() which is the one the documents alluded to, but showRows () which does make more sense in everyday language. Thanks again to Mr.Houdini on the Google forums.

Linking one cell to another in a spreadsheet

I have a dynamically generated spreadsheet. I would like to be able to allow the viewer to go to a different sheet/cell when a cell is clicked on. I'm having trouble figuring out a good way to do this.
Going to the new cell is fairly easy: Spreadhseet.setActiveSheet()/Spreadsheet.setActiveRange() work fine. My thought was to encode the link destination in the contents of the source cell, and then write a script to "follow" the link.
I tried using images or drawings. But there were two problems with this: while images can be inserted programmatically, I did not see a way to programmatically associate a script with them. And the called script does not have an associated event tied to it, so there is no way to see what cell the user clicked (clicking an image does not set the active cell).
I thought about using onEdit(). This almost works, but onEdit is only triggered on changes (not selection) so the user actually has to modify the cell in order to "link". When testing I tended to zap the contents of the cell by accident with onEdit.
I tried making a menu item, and in the menu's script get the active cell's contents to determine where to go to. This worked but was a bit more difficult for the user than I was hoping for.
I was hoping someone would have a creative solution to this problem.
Thanks!
From what you are describing the drawing or image insertion should work since it has exactly the same functionality as the menu item. You can assign a script to it just like in a menu.