Cell formating based on other cell value google sheets - regex

I have 2 sheets the first one is Orders and second one is the ShippingDoc.
At Shipping doc, I have Cell C2. In that cell I choose/write ID from range of A7:A from Orders.
Is there a way if I choose example ID 1 at C2 then automatically A7 at Orders to change background to green. Also if I change the ID to 2 the A8 to be green and to not delete the A7 color.

There is a better way of achieving this using Apps Script. Go to tools->Script editor and there use the following code (explained on the comments in the code):
// Update everytime the value on C2 changes
function onEdit() {
var spreadsheet = SpreadsheetApp.getActive();
// Get C2 value
var C2value = spreadsheet.getSheetByName("ShippingDoc").getRange('C2').getValue();
// If input value is higher than 0
if(C2value>0){
// Ofset to set the background after A7
var number = C2value+6;
// Set background color of appropiate cell
spreadsheet.getSheetByName("Orders").getRange('A'+number+'').setBackground('green');
}
}
Check out more information about how to do amazing things in sheets with simple scripts HERE
I hope this has helped you. Let me know if you need anything or if you did not understand something.

try:
=(REGEXMATCH(""&INDIRECT("ShippingDoc!C2"), ""&A1))*(A1<>"")

Related

Google sheets checkmark conditional Formating

I need help with Google spreadsheet checkmark conditional formatting. Please see the image for a better understanding. When I click on the C2 cells checkmark then automatically A2 cells $10 will be selected and added to the E5 cells. When I click on the B6 checkmark then automatically A6 cells $40 will be selected and added to the E5 cells. Summary of the concept: When I checkmark any cells (from B2 to B9 & C2 to C9) the same row (From A column) number will be added automatically to the specific cells(to E5 cells). How do I do it?
Sheet Link (I have given edit permission, you can edit it) - Go to sheet link
try:
=INDEX(SUM(IF(B2:C9=TRUE, A2:A9, 0)))
or:
=INDEX(SUM(IF((B2:B9=TRUE)+(C2:C9=TRUE), A2:A9, 0)))
or try:
=SUMPRODUCT((B2:B9=TRUE)*(C2:C9=TRUE)*A2:A9)
=SUMPRODUCT(((B2:B9=TRUE)+(C2:C9=TRUE))*A2:A9)
Try below formula-
=QUERY(A2:C9,"select sum(A) where B=True or C=True label sum(A) ''")

How can I calculate a new date conditionally based on other information?

I have a Google Sheet which is being populated by a Google Form. I am using Google Apps Script to add some extra functionality. Please feel free to access and modify these as needed in order to help.
Based on answers from the Form, I need to return a new date that factors in the time stamp at form submission.
This is a dumbed down example of what I need to do, but let's think of it like ordering a new car and its color determines how long it is going to take.
Car
Color
Toyota
Red
Honda
Blue
Tesla
Green
I need to write a conditional IF statement that determines how many weeks it will take to get the car based on the ordered color.
-
Red
Blue
Green
Toyota
1
3
5
Honda
2
4
6
Tesla
1
1
1
So if you order a Toyota in Red, it will take one week. If you order a Toyota in Green, it will take 5 weeks. If you order a Tesla, it will be really in one week no matter what color. Etc...
I started by writing some language in Sheets to take the Timestamp which is in Column A and add the appropriate amount of time to that:
=IFS(AND(B2 = "Toyota",C2 = "Red"),A2 + 7,AND(B2="Toyota",C2="Blue"), A2 + 21,AND(B2="Toyota",C2="Green"), A2 + 35,AND(B2 = "Honda",C2 = "Red"),A2 + 14,AND(B2="Honda",C2="Blue"), A2 + 28,AND(B2="Honda",C2="Green"), A2 + 42,AND(B2 = "Tesla"),A2 + 7)
And then I dragged that down the length of the entire column so that it would fill in as submissions came in.
However when you fill in the Google Form, it will overwrite what's in that entire row, blowing out what I had in that column.
Now I realized that the code needs to be written in Google Apps Script and returned as a value.
What kinds of modifications need to be made to my IFS statement in order to make it compatible with Google Apps Script?
For easier approach, QUERY would actually solve your issue without doing script as Broly mentioned in the comment. An approach you can try is to create a new sheet. Then have that sheet contain this formula on A1
Formula (A1):
=query('Form Responses 1'!A:C)
This will copy A:C range from the form responses, and then, copy/paste your formula for column Date Needed on column D.
Output:
Note:
Since you only copied A:C, it won't affect column D formula.
Your A:C in new sheet will update automatically, then the formula you inserted on D will recalculate once they are populated.
Add IFNA on your formula for column D to not show #N/A if A:C is still blank.
Formula (D2):
=IFNA(IFS(AND(B2 = "Toyota",C2 = "Red"),A2 + 7,AND(B2="Toyota",C2="Blue"), A2 + 21,AND(B2="Toyota",C2="Green"), A2 + 35,AND(B2 = "Honda",C2 = "Red"),A2 + 14,AND(B2="Honda",C2="Blue"), A2 + 28,AND(B2="Honda",C2="Green"), A2 + 42,AND(B2 = "Tesla"),A2 + 7), "")

Format a text on cell in two color in Coldfusion

Using Coldfusion 10, I need to format a cell contents in two color(Black and Blue). Let a cell on spreadsheet contains a string "Text1: Text2". where color of "Text1" should be black and "Text2" should be blue.
I have tried below code, but it produces all blue text.
SpreadsheetAddRow(spreadsheetData,"Text1: Text2",1,1);
format1=StructNew();
format1.color="black";
SpreadsheetFormatRow(spreadsheetData,format1,1);
format1.color="blue";
SpreadsheetFormatRow(spreadsheetData,format1,1);
How I can apply two color to format single cell ?
It is not supported with the built in functions. However, you can tap into the underlying POI library and use a RichTextString to accomplish this.
Assuming you have already created the worksheet and an empty cell:
spreadsheetData = SpreadSheetNew("Sheet1", true);
SpreadsheetAddRow(spreadsheetData,"",1,1);
Grab reference to the underlying Workbook and create fonts with the appropriate colors:
wb = spreadsheetData.getWorkbook();
Colors = createObject("java", "org.apache.poi.ss.usermodel.IndexedColors");
greenFont = wb.createFont();
greenFont.setColor(Colors.GREEN.index);
blueFont = wb.createFont();
blueFont.setColor(Colors.BLUE.index);
Then create a RichTextString object and append each part of the text with the desired color:
// Using GREEN and BLUE for demo purposes
richString = createObject("java", "org.apache.poi.xssf.usermodel.XSSFRichTextString").init();
richString.append("Text1: ", greenFont);
richString.append("Text2", blueFont);
Finally, apply the RichTextString to the empty cell, ie A1 you created earlier. Note, unlike in CF, the indexes are 0-based.
cell = wb.getSheet("Sheet1").getRow( 0 ).getCell( 0 );
cell.setCellValue(richString);

Different color for table of contents entry and page numbers

I am generating a clickable (=with links) table of contents. In order to emphasize the 'clickability' of the entries I want them colored as links (i.e. blue color and underline).
I have this code for setting the style:
toc = TableOfContents()
toc.levelStyles[0].fontName = 'Arial Bold'
toc.levelStyles[0].fontSize = 12
toc.levelStyles[0].textColor = '#0000cc'
and use this code to add each entry:
toc.addEntry(0, '<u>' + entrytext + '</u>', pageNum, str(id(page)))
It works ok, the problem is that page numbers turn out blue as well. I tried to look around SO and the user guide for ways to put a different style for each - but was unsuccessful. Any ideas?
Thanks.

MSChart HowTo Create a Second CursorX to have multiple Cursor by a second Transparant ChartArea?

I am try to introduce a Second CursorX at AxisX Primary if this is possible some how?
I did try to activate a second CursorX at Secondary but that one did not work as expected,
I also readed about Line Annotation and Vertical Line Annotation and created some kind of line but a Second set of CursorX CursorY would be far nicer
I did try to create and as much as empty as possible and Transparant Second ChartArea which i try to overlay on top of the ChartArea1, i noticed InnerPlotPosition and Postion of both ChartArea should stay in track to get a full aligned Overlay, and next the CursorX of second ChartArea should be displayed on top of ChartArea1
This is what i think how it could be done but don't have a clue if it sounda for a good way to create a second CursorX maybe Line Annotation is an easier road to rome
Any help suggestion are welcome
Thanks in advance
Suppose your chart contains multiple chart areas aligned vertically, below code allows you set CursorX in each chart area:
Dim c1 As New Chart
'...here code block to build each chart area ...
'...then use below sample code to align each chart area vertically:
'c1.ChartAreas(i).AlignmentOrientation = AreaAlignmentOrientations.Vertical
'c1.ChartAreas(i).AlignWithChartArea = c1.ChartAreas(0).Name
'below set horizontal cursor (it is a gold vertical bar in each chart area):
For Each area As ChartArea In c1.ChartAreas
area.CursorX.LineColor = Color.Gold
area.CursorX.LineWidth = 3
area.CursorX.IsUserEnabled = True
area.CursorX.IsUserSelectionEnabled = True
area.CursorX.SelectionColor = System.Drawing.Color.PaleGoldenrod
Next