How to change the color of a bar of a chart in google sheets when a cell is populated for the bar's row - google-apps-script

I have a google sheet that I'm working to test a small dashboard on. My goal is to show the time some units are out of manufacturing and heading to the finishing department for polish, coloring, etc. What I want to achieve is to have the color of the bar for the associated row to change color when one of the cells is populated. In my googling, I've managed to find bits and pieces, but I don't know enough JavaScript to be able to take the things I have found and use them, let alone understand them for the most part.
Here is the test sheet I've been working on: https://docs.google.com/spreadsheets/d/1b09CKYbrxe7riS6mXx6OfQk4TrQcBcghU4_YvuIt1lA/edit?usp=sharing
Basically, I want for the D Column to change the row's bar on the second tab of the spreadsheet.
I do understand it would be an onEdit(e) function and an IF statement to make it work. As well, a second function for changing the bars, but I don't know what that would be.

Related

Filter Checklist, Copy/Paste Range to another Sheet (Location Based on Word Match), Insert New Rows as Needed, initiate on Button Click, Reset Sheet

So I'm working in Google Sheets using Apps Script, on a spreadsheet that has 4 tabs. Names are: "Testing Plan","Blue Test Catalog", "Red Test Catalog", "Green Test Catalog".
On the Catalog Tabs, I want the Leads to go in, and click all the checkboxes for all the tests that need to be completed. So Blue Lead reviews and assigns all the Blue Tests from the Blue Test Catalog, and Red/Green Leads do the same. Once each person has checked all their boxes, they click a button on their sheet "Add To Plan".
All of the checked boxes and their rows from their tab are then copied over to the Testing Plan tab, under the corresponding Test Section (Blue Tests, Red Tests, Green Tests). So I have one neat doc that lists all the tests in one place by their category.
The trick is, I need the code to be able to insert enough blank rows under each section to accommodate the list of items being copied over from each section.
I then want to be able to clear the doc and "reset it" back to how it looks now, as needed (via button click).
I'm not good at coding - its not a normal part of my job. But I've been able to piece some things together over the years based on my google searching and this website, so I thought I'd reach out for help. I unfortunately don't even have any sample code to work off of. I've spent 2 full days attempting this and keep deleting. I've managed to at least write a script to copy and paste a range based on whichever button/sheet location I'm at, but it copies to the bottom of the page. I can't figure out how to do a list filter based on checkbox value being TRUE, and then only copy and paste those values. And then I'll need to figure out how to have the code search and match 'Blue Tests' from the Blue Test Catalog tab with the word 'Blue Tests' on the Test Planning Tab and paste 4 rows down from that, inserting new rows as needed to ensure no overwriting.
Any help would be appreciated. Sample Sheet here.
Why not doing it with this simpler way
={"Blue test","","","","";query('Blue Test Catalog'!A3:AG,"select B,K,N,Q,X where A=true",1);
"","","","","";
"Red test","","","","";query('Red Test Catalog'!A3:AG,"select B,K,N,Q,X where A=true",1);
"","","","","";
"Green test","","","","";query('Green Test Catalog'!A3:AG,"select B,K,N,Q,X where A=true",1)}
I add some conditonal formatting
something possible to do to split the formula in 5 packages

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.

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.