How do I rearrange excel values? Sorry hard to explain without example - excel-2003

It is difficult to explain in words, so I have to show it instead:
Basically I have this:
And I want it to look like this:
Is there a formula that will let me create something like column B?
There's more countries than this in the actual excel (2003) file, and I cannot do this manually, as I'm planning to use data in column B to link to another formula in column C. Ultimately I want to be able to enter data manually elsewhere, and have column A filter the relevant countries (it already does this), column B to arrange them properly like the second image file, and column C to use that to calculate other stuff. I'm not very good at explaining so if I'm not making sense please say so.
EDIT: I'm trying to show this in words as well, but I don't really know how to format this, so sorry in advance
So basically I have this:
A ------ B ------ C
Japan
US
Germany
Indonesia
Malaysia
Vietnam
And I want it to look like this:
A B C
Japan
US
Germany
Indonesia
Malaysia
Vietnam
Sorry I know the formatting is bad I have no idea how I did the second part, but basically in the first one there's gaps in between countries in column A (e.g. A1 - Japan, A2 - US, A5 - Germany, A11 - Indonesia, A12 - Vietnam etc.) and I want column B to be B1 - Japan, B2 US, B3 - Germany, B4 - Indonesia, B5 - Vietnam ... does that make sense?

This is simply what you want Remove Blanks. Credits to Oscar Cronquist.
If the link is somehow broken, you use this formula in B1. Copy or auto-fill to other cells.
Change the range to suit.
=IFERROR(INDEX($A$1:$A$30, SMALL(IF(ISBLANK($A$1:$A$30), "", ROW($A$1:$A$30)-MIN(ROW($A$1:$A$30))+1), ROW(A1))),"")
This is an array formula entered by Ctrl+Shift+Enter.
Edit1: ISERROR Equivalent
=IF(ISERROR(INDEX($A$1:$A$30, SMALL(IF(ISBLANK($A$1:$A$30), "", ROW($A$1:$A$30)-MIN(ROW($A$1:$A$30))+1), ROW(A1)))),"",INDEX($A$1:$A$30, SMALL(IF(ISBLANK($A$1:$A$30), "", ROW($A$1:$A$30)-MIN(ROW($A$1:$A$30))+1), ROW(A1))))
Result:

Related

Stack multiple queried Importranges with a single word between the two sets of imported data?

I have a master sheet that contains all of the data for other sheets. Column A in the master sheet is the name for who's sheet it will import to. So if the name is "John" then every row that has "John" in column A from the master sheet will be imported into John's sheet. I have the person's name in cell G1 of their own respective sheet and use the following formula.
=ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"'",0),""))
Master sheet looks like this:
Assigned To
Name
State
City
John
Blake G.
Arizona
Phoenix
Andy
Chase C.
Arizona
Phoenix
John
Amy B.
New Mexico
Santa Fe
John
Bill S.
Texas
Austin
John's sheet will look like this:
Name
State
City
Blake G.
Arizona
Phoenix
Amy B.
New Mexico
Santa Fe
Bill
Texas
Austin
I want to separate the data based on what is in Col17 and put a single word between the two data sets. Col17 has either a Y or a N so I can just add AND Col17='N' to the existing formula. I double up the formula, but changed the last condition to be Col17='Y' so that I can pull the two data sets separately and on top of each other.
={ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='N'",0),""));ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='Y'",0),""))}
What I want to do is add a single word between the two imported sets of data. It should like kinda like this:
Name
State
City
Blake G.
Arizona
Phoenix
Amy B.
New Mexico
Santa Fe
Inactive
Bill
Texas
Austin
I added the word inactive so the middle looks like ""));"Inactive";ARRAY between the two formulas but because of how Query works I get an error saying the array lengths for each formula do not match. Is there alternative to help make this happen or will I need to figure out a workaround with something that isn't Query?
SUGGESTION
Feel free to comment below if ever your question has been misunderstood.
In my understanding, here's your process:
The first formula will list all data that has N value in Col17 .
The second formula will list all data that has Y value in Col17.
This second formula should also have an Inactive title header.
Merge the two formulas separated by the word "Inactive".
If I got it correctly, you could use the label clause to add "Inactive" in your second Query function as seen on this tweaked formula:
={ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("SHEET_URL","A1:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1 = '"&G1&"' AND Col17 = 'Y'"),0));ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("SHEET_URL","A1:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1 = '"&G1&"' AND Col17 = 'N' label Col2 'Inactive'"),0))}
Demo
Sample result.
E.g. If there's new data added that should be under "Inactive".
Main Sheet
John's Sheet
#SputnikDrunk2 is a very good workaround. Just in case you decide to stack different types of ranges that are not queries, you should consider that they need to have the same amount of columns. So if you add a new row it should have the 12 columns you have from your Queries. One way would be like this:
={ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='N'",0),""));
{"Inactive","","","","","","","","","","",""};
ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='Y'",0),""))}
Another option to avoid creating so many "","","","" is to use this "trick" that divides a range by 0, and with IFERROR it returns empty cells:
{"Inactive",INDEX (IFERROR(SEQUENCE(1,11)/0,))};
Here's another approach:
=lambda(z,
{filter(choosecols(z,2,3,4,5,6,7,8,9,10,11,12,13),index(z,,1)=A1,index(z,,17)="N");
{"Inactive",makearray(1,11,lambda(r,c,iferror(1/0)))};
filter(choosecols(z,2,3,4,5,6,7,8,9,10,11,12,13),index(z,,1)=A1,index(z,,17)="Y")}
)(A1:Q4)
A1:Q4 part in the formula should be replaced with your importrange Fx
2,3,4,5,6,7,8,9,10,11,12,13 part can also be replaced with shorter sequence(1,12,2,1)

Pick the first duplicat value ($R$4:$R) based on each of them must be have high number on column ($T$4:$T) with arrayformula

I want to make a duplicat value which are refferance from ($R$4:$R) column. Based on each have a highest number of them on column of ($T$4:$T) as a criteria and want to do this all with arrayformula.
I've tried my formula on "T E S T" column on (AE3) but it doesn't gave me the rights output as I want as I imagine it.
See the pic I atteched here below :
And my gsheet's doc please feel free to edit because I hope that you will. It makes me happy ^_^ :
Example link
Try this formula. It seems to work in Column AF
=filter(If(IFERROR(match(R4:R,R:R,0),0)=ROW(R4:R),R4:R,""),R4:R<>"")

Matching Columns From Different sheets

There are many similar questions on here but I can not find the answer I am after.
I am working in Google Sheets and need to write a conditional formatting equation that will highlight the B:C columns if they match an entry on the second sheet in the B:C columns. I do not know any search criteria past that which is where I keep running into an error. All the other questions here know what they are searching for. My work is fluid and new entries come in that may match an old one and I need to know that!
I use this formula on the first sheet to match entries specifically on the first sheet,
=COUNTIF(ARRAYFORMULA($B$3:$B$389&$C$3:$C$389),$B2&$C2)>1
This formula works great. If Lexington, SC is in row 2 and Lexington, SC is added again later in row 100, BAM they both light up red. Love that. The second equation I need is not so simple.
my data is:
SHEET 1 - Column B and Column C
County
State
Lexington
SC
Douglas
KS
Chase
KS
Clay
OH
Greenwood
NY
SHEET 2 - Column B and Column C
County
State
Saratoga
NY
Douglas
KS
Chase
KS
Clay
OH
Greenwood
SC
In this example above, I need the new formula to highlight Douglas KS, Chase KS, Clay OH on sheet one, because these three counties exists on Sheet Two.
I have tried MATCH, INDEX, VLOOKUP, etc. I keep running into an issue when I want TWO columns to be compared to TWO columns. It needs to be county name AND state.
Thank you to the community for any help you can give. I will provide more information if it is needed! I think this sums up my issue though.
QUERY ATTEMPTS
=COUNTIF(ARRAYFORMULA($B$2:$B$20&$C$2:$C$20),$B2&$C2)>1
=COUNTIF(ARRAYFORMULA('Sheet 2'!$B$2:$B$20&$C$2:$C$20),$B2&$C2)>1
=COUNTIF(ARRAYFORMULA(indirect("Sheet1!$B$2:$B$C$2:$C"),indirect("Sheet2!$B2:$B&$C2:$C")))>1
=ARRAYFORMULA(IFERROR(VLOOKUP(B2:C,"Sheet 2!$B2:$C",2, FALSE),""))
=ARRAYFORMULA(INDEX(B2:B19, MATCH(1, FIND(E2, C2:C19)), 0))
=ARRAYFORMULA(INDEX(B2:C,MATCH(indirect("Sheet 2!$B2:$C"),0)))
=MATCH($B2&$C2,indirect('Sheet 2'!$B2:$B&'Sheet 2'!$C2:$C"),0)
=MATCH($B2,indirect("Sheet 2!$B2:$C"),0)
=MATCH("Sheet 1!$B2&$C2",indirect("Sheet 2!$B2:$C"),0)
=MATCH("Sheet 1!$B:$C"),indirect("Sheet 2!$B:$C"),0)
=MATCH((B2&C2),indirect("Sheet 2!(B2&C2)"),0)
=INDEX($B2:$C2,MATCH($B2&$C2,indirect("Sheet 2!$B2:$C"),0)
=INDEX(B:C,MATCH($B2&$C2,indirect("Sheet 2!$B2:$C"),0)
=INDEX(B2:C710,MATCH(0,(B:C="Sheet 2!$B:$C"),0))
The only query I have gotten to work only works on the B column
=match($B2,indirect("Ready to Start!$B2:$B"),0)
in conditional formatting (and data validation) whenever you want to refer to another sheet, that sheet's range needs to be INDIRECTed. if you got a joint range (like you do) both of them need to be wrapped in INDIRECT
try:
=COUNTIF(ARRAYFORMULA($B$3:$B$389&$C$3:$C$389),
INDIRECT("Sheet 2!B2")&INDIRECT("Sheet 2!C2"))>1
or:
=COUNTIF(ARRAYFORMULA(INDIRECT("Sheet 2!B3:B389")&INDIRECT("Sheet 2!C3:C389")),
$B2&$C2)>1
but note that this will work only if let's say B4&C4 on BOTH sheets are the same.
if one sheet compared to other has different sorting of the same values you will need a completely different formula...
if your sheets are named exactly:
Sheet 1
Sheet 2
try this in Sheet 1:
=($A2<>"")*REGEXMATCH($A2&$B2, TEXTJOIN("|", 1,
INDIRECT("Sheet 2!A2:A")&INDIRECT("Sheet 2!B2:B")))

Google Sheets Hyperlink to Dynamic Field Within a Given Sheet

I have a Google Sheets document with a series of fields for every day in the year. The top row (Actually, row 2) is the Months (by full name, eg. January, February, etc.). The A column is numeric, from 1 to 31. There are several fields for each date, so the fields in the A column are merged (in other words, it's not A2, A3, A4 - more like, A2, A7, A12).
What I'd like to do is put a a hyperlink at, say, B1, that points to "today's" top field. So, today's would point to J7, and I could just click the link at B1, and get taken directly to that field.
I know this is going to involve the HYPERLINK function, but I can't figure out how to get it to work. Something like:
=HYPERLINK("#gid=0&#range=" & MATCH(TEXT(TODAY(),"MMMM"),2:2,0) & MATCH(DAY(TODAY()),A:A,1),"Click for today")
But I can't get it to work right. Any thoughts?
Assuming your months are in every column from B2:M2:
=HYPERLINK("#gid=*000000000*&range="&ADDRESS(MATCH(DAY(TODAY()),A2:A,1)+1,MONTH(TODAY())+1,4),"Click for today")
I wrote the formula so that the link could go in A1 without running into trouble, if you like. (It would also work in B1, etc.)
If there are spaces between your months, just reorder what you had so the MATCH for the row is first and wrap it in ADDRESS( row, column, 4):
=HYPERLINK("#gid=*000000000*&range="&ADDRESS(MATCH(DAY(TODAY()),A2:A,1)+1,MATCH(TEXT(TODAY(),"MMMM"),2:2,0),4),"Click for today")
(To be clear for future users, you'd need to replace the gid= number with the actual number corresponding to your sheet.)
Eric Tyler - Close. But it got me where I needed to be, so thank you so much. I was missing two key funtions: ADDRESS, and SUBSTITUTE. Here's what wound up working. (Note: In my case, the gid is 0.)
=HYPERLINK("#gid=0&#range="&SUBSTITUTE(ADDRESS(MATCH(DAY(TODAY()),A:A,1),MATCH(TEXT(TODAY(),"MMMM"),1:1,0)),"$",""),"Click here")
The ADDRESS line the way you proposed it results in the address in the format $A$1, which the HYPERLINK function doesn't like. Using that just brought be to the sheet, but not the actual cell. By using SUBSTITUTE to get rid of the $ marks, that resolved the problem.)
Thanks again!

How can I make an statement to output different things based on other cells

I'm writing a spreadsheet for a planning of some sort. It is about a band with multiple musicians on sometimes the same instruments. I've made two sheets. One for the musicians to let them show when they'll be present, while the other has to make an overview of all musicians present on certain dates.
I've already made an if statement to show when one of them is present, which would look like this in simple code:
if(B2)
print("Eric")
What I actually would want is an if statement to show when they are both present. In simple code it would look like this:
if(B2)
print("Eric")
if(B2 && C2)
print(", ")
if(C2)
print("Frank")
Really simplified.
I've made an example spreadsheet to show what I've already got. Here it is:
https://docs.google.com/spreadsheets/d/17gyoh5NUdiUWB_Nq0w3FAc1OsWQygzRYd_kzm0ijdJA/edit?usp=sharing
So what I would like to see with input as: B3=TRUE, C3=TRUE.
in sheet2 it should then show in B3: Eric, Frank
How about this answer? I think that there are several answers for your situation. So please think of this as one of them.
Sample formulas:
Please put 1st and 2nd formula to "B3" and "C3" of Sheet2, respectively.
=TEXTJOIN(", "; TRUE; ARRAYFORMULA(IF(Sheet1!B3:C3=TRUE; Sheet1!$B$2:$C$2;)))
and
=TEXTJOIN(", "; TRUE; ARRAYFORMULA(IF(Sheet1!D3:G3=TRUE; Sheet1!$D$2:$G$2;)))
Retrieve values that the checkbox is checked using IF and ARRAYFORMULA().
Join the retrieved values using TEXTJOIN().
Result:
For example, when B3, C3, E3 and F3 of Sheet1 are checked, Sheet2 becomes as follows.
References:
ARRAYFORMULA
TEXTJOIN
If I misunderstand your question, I'm sorry.

Resources