Update formulas from cell string - google-sheets

I have a sheet with a multitude of formulae for generating reports. Examples of the formulae are:
=countifs(Wk27_28_data!Z:Z,"no",Wk27_28_data!J:J,"<>Update",Wk27_28_data!J:J,"<>With Customer",Wk27_28_data!J:J,"<>In Progress",Wk27_28_data!C:C,"<>Change",Wk27_28_data!J:J,"<>With Supplier")
=Wk27_28_data!B5
=countifs(Wk27_28_data!D:D,A6,Wk27_28_data!C:C,"Automated Alert")
=COUNTIF(Wk27_28_data!F:F,A29)
Ideally what I want to be able to do is remove the 27_28 from the formulae and put it in to another cell which is then referenced by all the formulae, and thus I would be able to update them all just by changing this one cell. Does anyone know how I would accomplish this?

use:
=COUNTIFS(INDIRECT("Wk"&A1&"_data!Z:Z"), "no",
INDIRECT("Wk"&A1&"_data!J:J"), "<>Update",
INDIRECT("Wk"&A1&"_data!J:J"), "<>With Customer",
INDIRECT("Wk"&A1&"_data!J:J"), "<>In Progress",
INDIRECT("Wk"&A1&"_data!C:C"), "<>Change",
INDIRECT("Wk"&A1&"_data!J:J"), "<>With Supplier")
=INDIRECT("Wk"&A1&"_data!B5")
=COUNTIFS(INDIRECT("Wk"&A1&"_data!D:D"), A6,
INDIRECT("Wk"&A1&"_data!C:C"), "Automated Alert")
=COUNTIF(INDIRECT("Wk"&A1&"data!F:F"), A29)
where A1 cell = 27_28

Assuming Wk27_28 text is entered in cell A1. Replace
=Wk27_28_data!B5
with
=INDIRECT("Wk"&$A$1&"_data!B5",TRUE)
and do the same for others.
Please share if it works/understandable/not.

Related

Google spreadsheet change a cell depending on what is written on another cell

In a cell I have a list of locations made with data validation. Example Budapest, Belgrade, Bucharest.
next to the cell I have formula that i have to change manually if i change the cell with the location, EX: =index( Budapest!I:I; max(if(Budapest!B:B=E127; row(Budapest!B:B)))), =index( Belgrade!I:I; max(if(Belgrade!B:B=E127; row(Belgrade!B:B))))...etc
Is it a way to change automatically the formula, for ex if I select the city Budapest the formula to change to Budapest.
I have tried: =if(F127="Budapest"index( Budapest!I:I; max(if(Budapest!B:B=E127; row(Budapest!B:B))))) if(f127="Belgrade"index(Belgrade!F:F; max(if(Belgrade!B:B=E127; row(Belgrade!B:B)))))
if A1 = Bucharest (or whatever else) use:
=INDEX(INDIRECT(A1&"!I:I"); MAX(IF(INDIRECT(A1&"!B:B")=E127; ROW(INDIRECT(A1&"!B:B")))))
Depending on where the input data is will determine what the best formula to use it. But to be vague, the answer is yes. It will most likely require you to use a formula that pulls data and instead of the putting in a location of where to pull from, put a cell reference. Some formulas wont let you use a cell’s contents to reference a location. In that case you can concatenate the string from a cell into the formula. Here is an example of concatenation within a formula that does not allow cell references (query select where).
=QUERY('tab1'!$A$4:$R, "select * where A = '"&$C$5&"'")
It pulls all data where column A matches whatever value is typed into cell C5.
I understand this formula does not match your data but it provides an explanation of the mechanism of how to do so. I hope it helps. If not, please provide an example sheet and I can create a specific formula for your situation.

Google Sheets formula to leave cell empty based on conditions

I'm having issues with this formula:
=ARRAYFORMULA("WORD"&" "&sheet1!$B$20&" "&'sheet2'!A2:A&" "&sheet1!$B$17&'sheet2'!B2:B)
What I want is to leave empty cell if there is no data available in sheet 2 and when the data is added in the sheet (sheet2) the formula auto populates the results in the third sheet, where the formula is placed.
Tried with If function, but I'm getting Errors.
Thanks in advance for the help.
=ARRAYFORMULA(IF('sheet2'!A2:A="","","WORD"&" "&sheet1!$B$20&" "&'sheet2'!A2:A&" "&sheet1!$B$17&'sheet2'!B2:B))

Highlight duplicates within cells

Help needed finding duplicate words with single text cells in google sheets?
Data has trim function applied.
e.g =if(B10"",""trim(concatenate($I$3," ",trim(B10)," ",$J$3)))
Tested solution needs some modifications
Requirement number of duplicates in one cell in not important, it can be any word, in any position, it has to match exact word and duplicates should not be removed.
For example, in a cell: "Great Great Expectations" formula should detect “Great” repeated twice, and where no duplicate words are found no change should happen
Desired outcome would be to highlight entries with duplicate entries in column "I" or create message box listing duplicate entries.
Tested solutions include vlookup and array formula as standalone "dupe" "no dupe" comparison.
Only Solution that provide any success was
=IF(SUM(N(IFERROR(FIND(" "&MID(A2,ROW(OFFSET(A$1,,,LEN(A2))), MMULT(FIND(" ", {""," "} &A2&" ",ROW(OFFSET(A$1,,,LEN(A2)))),{1;-1}))&" ", " "&A2&" "), LEN(A2)+1)<ROW(OFFSET(A$1,,,LEN(A2)))))>0, "Dupes", "All good")
This return consistently correct result for standalone data, but I have not sure how to modify this to.
Run automatically
Highlight Cells with Duplicates
Open to any solutions
Thanks in advance
#Harun24Hr
Array Formula Returns "1" for blank lines
and Ref range error for any other cell.
Conditional Formatting is applying Colour formatting to entire range, with data no longervisible.
Any ideas
Thanks
Try below formula. When you will apply formula to conditional formatting then it will apply to all cells automatically for selected range.
=ArrayFormula(INDEX(SORT(COUNTIFS(TRANSPOSE(SPLIT(A1," ")),UNIQUE(TRANSPOSE(SPLIT(A1," ")))),1,FALSE),1)>1)
Conditional formatting settings.

Concatenate cells based on a condition

I look for the following: I have columns with part names that make up a particular product, where I inform if the parts are defective or not. When the part is OK the default information is set to "#". All defects have a depreciation value from 0 to 10.
I want to concatenate in one cell all the defects that depreciate the product. In another cell, the defects that do not depreciate.
Here's the test sheet:
https://docs.google.com/spreadsheets/d/1HX2eko7v15mDja6_KlajmUaHkY4SCmKfELvPxqgnDUA/edit#gid=0
Actually I got a solution, however, there are 18 columns and the formula will be very large. Could someone come up with a smarter solution?
Here's my current script:
=IFERROR(CONCATENATE(LEFT(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)<>0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)<>0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)<>0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)<>0;D2&", ";"");""));LEN(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)<>0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)<>0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)<>0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)<>0;D2&", ";"");"")))-2);".");"OK")
and
=IFERROR(CONCATENATE(LEFT(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)=0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)=0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)=0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)=0;D2&", ";"");""));LEN(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)=0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)=0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)=0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)=0;D2&", ";"");"")))-2);".");"OK")
paste in D2:
=ARRAYFORMULA(REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(
IF((A2:D<>"")*(A2:D<>"#"); A2:D&","; ));;999^99))); ",$"; "."))
paste in E2:
=ARRAYFORMULA(IF(B2:B<>""; IF(B2:B="#"; "OK" ; B2:B)&"."; ))
spreadsheet demo

Google Sheets - Replace Duplicate cells with =[cell]

I've got a google sheet with duplicate cell values. I was wondering if there's a quick and easy way to replace all those duplicates with a reference to just one of them, i.e "=[cell]".
yes, this is possible to do with formula.
Paste this in B2 and copy the formula down:
=if(countif($A$2:A2,A2)>1,"["&ADDRESS(MATCH(A2,A:A,0),COLUMN(A2),4)&"]",A2)
Then to get actual cell refference, use script:
this formula makes text looking like reference: =if(countif($A$2:A2,A2)>1,"="&ADDRESS(MATCH(A2,A:A,0),COLUMN(A2),4),A2)
script must getValues and then setFormulas to range B2:B

Resources