block changes in data validation if another cells says approved - validation

Please help me. This is on Google Sheets
I have cell A1 B1 C1 and D1
A1 - manual input
B1 - drop down list using Data Validation
C1 - manual input
D1 - approval cell
What I want to happen is, restrict edit on A1 B1 C1 if D1="Approved"
While it is already doable for cells A1 and C1 using data validation custom formula,
How will I do it for cell B1?
Thanks for your help!

Related

How to transform a process model into a code?

I need to tranform this scheme of the process flow into a code using only the functions in the table. I think, that there should be a loop after a decision if C1 or C2 is true, but I do not know how to exit the loop afterwards. Bold circle in the right is the final state. enter image description here
The break statement can be used to jump out of a loop.
IF (C1 != TRUE AND C2 != TRUE)
BREAK;

Dynamic data validation based on other cell values, and copying/filling validation criteria relatively down each row (Google Sheets)

I am trying to achieve the following situation using Data Validation in Google Sheets. I've provided a truncated version of situation in the image below.
I would like to set up data validation in Column B that automatically checks the options in column C (or multiple columns in the same row) to populate the dropdown menu for that row.
I did notice that Google Sheets has an option for formulas in the data validation screen and I tried writing an array formula in this area but I have not been having any luck getting any sort of output.
If it can't be done through this menu I would appreciate any idea how to achieve this through scripts.
One way to achieve this is to select list from a range in the "Criteria" section of the Data Validation editor. Then, select the cells whose values you want to appear in your dropdown.
The only issue is that when you try to fill this down across the column, Google Sheets will not update the criteria range. Say you do the following:
In cell B2, use data validation based on list from a range and select D2:F2 as the criteria range. Now the dropdown in B2 will have the options John's Mom, John's Dad, John's Grandma
Then, fill down or copy this cell down across the whole column
When you open the dropdown for cell B3, it will still have the options John's Mom, John's Dad, John's Grandma
Unfortunately Google Sheets does not currently have a built-in solution for copying/filling data validation references or formulas relatively, as far as I know. But it looks like somebody already wrote a nice script in this Google Docs forum post. To avoid just a link as an answer, I'm going to copy in the script and instructions here. Credit to AD:AM from Google Docs forum.
How to use their script:
Select a range of cells across which you want to copy a data validation rule, relatively
From the Validation+ custom menu, select the appropriate option (all references relative, columns absolute, or rows absolute)
The validation of the upper-left cell will be copied to the rest of the range
Link to original solution's example Google Sheets with script already included - you can save your own copy and then start using.
Or to recreate from scratch, here is the script.
function onOpen()
{
SpreadsheetApp.getActiveSpreadsheet().addMenu
(
"Validation+",
[
{name: "Copy validation (all relative references)", functionName: "copyValidation"},
{name: "Copy validation (relative rows, absolute columns)", functionName: "copyValidationColumnsAbsolute"},
{name: "Copy validation (absolute rows, relative columns)", functionName: "copyValidationRowsAbsolute"}
]
);
}
function copyValidation(rowsAbsolute, columnsAbsolute)
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var r = ss.getActiveRange();
var dv = r.getDataValidations();
var dvt = dv[0][0].getCriteriaType();
if (dvt != SpreadsheetApp.DataValidationCriteria.VALUE_IN_RANGE) return;
var dvv = dv[0][0].getCriteriaValues();
Logger.log(dvv);
for (var i = 0; i < dv.length; i++)
{
for (var j = i ? 0 : 1; j < dv[0].length; j++)
{
dv[i][j] = dv[0][0].copy().withCriteria(dvt, [dvv[0].offset(rowsAbsolute ? 0 : i, columnsAbsolute ? 0 : j), dvv[1]]).build();
}
}
r.setDataValidations(dv);
}
function copyValidationRowsAbsolute()
{
copyValidation(true, false);
}
function copyValidationColumnsAbsolute()
{
copyValidation(false, true);
}

Terminal dashboard in golang using "termui"

I am working on drawing graphs on the terminal itself from inside a go code.I found this (https://github.com/gizak/termui) in golang. And used this(https://github.com/gizak/termui/blob/master/_example/gauge.go) to draw graph in my code.
Problem is this , as we can see in the code( https://github.com/gizak/termui/blob/master/_example/gauge.go ), they are passing g0,g1,g2,g3 all together in the end "termui.Render(g0, g1, g2, g3, g4)".
In my case I don't know how many gauges to draw before hand so I used a list to store gauge objects and then tried to pass list to render.
termui.Render(chartList...)
But it creates only one gauge.
This is how I am appending elements in the list.
for i := 0; i < 5; i++ {
g0 := termui.NewGauge()
g0.Percent = i
g0.Width = 50
g0.Height = 3
g0.BorderLabel = "Slim Gauge"
chartList = append(chartList, g0)
}
what I am getting is a gauge for i=4 only. when I am doing termui.Render(chartList...)
Am I doing something wrong?
PS - I have modified question based on the answer I got in this question.
Here is a good read on Variadic Functions
Take a look at the function signature of Render, https://github.com/gizak/termui/blob/master/render.go#L161
func Render(bs ...Bufferer) {
All you need to do is
termui.Render(chatList...)
assuming chartList is a []Bufferer
Edit
You are only seeing one because they are stacking on top of one-another. To see this add
g0.Height = 3
g0.Y = i * g0.Height // <-- add this line
g0.BorderLabel = "Slim Gauge"
From a quick review of the project, it appears there are ways for auto-arranging that have to do with creating rows (and probably columns). So you might want to explore that, or you will need to manually position your elements.

Is it possible to use a conditional validation rule as a custom formula in validation box in Google Spreadsheet?

I would like to set a validation in Column D (please see the published spreadsheet at the link below [1]) in such a way that it only shows the items of either column A (A3:A) or B (B3:B) (but not all the items of both columns together) depending upon the Service which is put in Col. C.
So, if somebody put "Typing Services" in C3, the cell D3 has a validation having all the items of column A (A3:A) only. And similarly, if somebody put "Translation Services" in C3, the cell D3 has a validation having all the items of column B (B3:B) only.
I believe a custom formula in validation box in column D can do it. However, i am unable to produce it.
Thank you for your solution!
[1]https://docs.google.com/spreadsheets/d/1XdcKbxKvIOSFK37zwULZns6giE9ounHPS5iHrRFkvIk/edit#gid=697587372 [1]
This should do what you want. Add this to your script editor:
function onEdit(event){
var ss=SpreadsheetApp.getActiveSpreadsheet()
var s=ss.getSheetByName("custom formula in validation")
var sheet = event.source.getActiveSheet().getName();
var lr=event.source.getActiveSheet().getLastRow()
var editedCell = event.range.getSheet().getActiveCell();
var editVal=event.range.getSheet().getActiveCell().getValue()
var editRow=event.range.getSheet().getActiveCell().getRow()
if(sheet=="custom formula in validation" && editedCell.getColumn() ==3){
if(editVal=="Typing Services"){
var validation=s.getRange(3, 1, lr,1)
var cell= s.getRange(editRow,4,1,1)
var rule = SpreadsheetApp.newDataValidation().requireValueInRange(validation).build();
cell.setDataValidation(rule);
}
if(editVal=="Translation Services"){
var validation=s.getRange(3, 2, lr,1)
var cell= s.getRange(editRow,4,1,1)
var rule = SpreadsheetApp.newDataValidation().requireValueInRange(validation).build();
cell.setDataValidation(rule);
}}}
This is a share of my test spreadsheet:
https://docs.google.com/spreadsheets/d/10lQnZ3m6wJYAC29ylZEM1Yj2vCzKljcE9zGZNn-bRiQ/edit?usp=sharing

Write google sheets script to Randomly pick from a range of cells and print in a cell

So want to write a script in google sheets that will be activated with a button. For example I have A1 says "Option 1",A2 says "Option 2", A3 says "Option 3". I want to make a button that when i press it, it will randomly pick from A1-A3 and print it in A4. So it will print one of the 3 cells Option 1, Option 2, or Option 3, into another cell into Cell A4
Put this in A4:
=index(A1:A3, randbetween(1, counta(A1:A3) ) )
Then attach this function to your button:
function random() {
var ss=SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var val=ss.getRange("A1").getValue()
var clr =ss.getRange("A1").clearContent()
ss.getRange("A1").setValue(val)
}
The clear and set is needed to make the formula recalculate. This will get whatever value is in A1.

Resources