I have an Excel spreadsheet such as this: (See Columns A through D of "Formula Output Column E" image - had to remove original 1st image due to not enough reputation points)
And would like to make a formula to consolidate it so that when the first three columns are duplicates, the last column gets combined into one CSV cell such as this: Excel Finish
I'm thinking it can get there with the right combination of Index and Match functions, but I haven't gotten it to work yet.... any help would be much appreciated! Thanks.
I currently have the following formula:
=IF(AND(A2=A1,C2=C1),"",D2&",
"&INDEX(A2:D17,MATCH(A2,A2:A17,0)+1,4)&",
"&INDEX(A2:D17,MATCH(A2,A2:A17,0)+2,4)&",
"&INDEX(A2:D17,MATCH(A2,A2:A17,0)+3,4)&",
"&INDEX(A2:D17,MATCH(A2,A2:A17,0)+5,4))
Which yields this ouput in Colum E: Formula Output Column E
As you can see, it either includes too many rows (Row 2 and 6 output) or too few (Row 8 output). Hope this helps, thanks.
If you have two extra columns and type
=IF(AND(A2=A3,C2=C3),D2&","&E3,D2)
in cell E2 and
=IF(AND(A2=A1,C2=C1),"",E2)
in cell F2 like in the following example
Then you will get the output for column CSV Output correct but in row F instead of row E, as below when you fill the formula to the bottom.
Here is the array formula (means you have to click Ctrl + Shift + Enter altogether) you can use in your CSV Output column:
{=IF(OR(ROW(E1)=1,MAX(--($A$1:A1=A2)*--($B$1:B1=B2)*--($C$1:C1=C2)*ROW($A$1:A1))=0),D2,INDEX($E$1:E1,MAX(--($A$1:A1=A2)*--($B$1:B1=B2)*--($C$1:C1=C2)*ROW($A$1:A1)))&", "&D2)}
Here is the explanation but I also included a picture for your reference:
Column F: This is to find the last matched row and this is also an array formula:
{=MAX(--($A$1:A2=A3)*--($B$1:B2=B3)*--($C$1:C2=C3)*ROW($A$1:A2))}
The -- just easy to see when you evaluate formulas. You can remove them if you want.
Column G: This is to concatenate the prior outcome:
=IF(OR(ROW(G1)=1,F2=0),D2,INDEX($G$1:G1,F2)&", "&D2)
Hope this helps. Please let me know if you have any question.
Related
I am trying to create an output in excel based off the number of words in cells. Essentially i want to check if the sum of the words in 3 cells is = 1,2 or >=3. Im using the len formula which i have successfully used on single cell conditions but im struggling to create the formula that would check multiple cells.
Below is an example of my data:
Column A Column B Column C
Cat;dog Bird
Formula
=SUMIF(AND(LEN(TRIM(A4))-LEN(SUBSTITUTE(B4," ",""))+1, LEN(TRIM(C4))-LEN(SUBSTITUTE(C4," ",""))+1, >=3), "Titanium")
https://docs.google.com/spreadsheets/d/1W6nFr-W0r-XWZnvrFWndsvdBEEGHMQUa/edit?usp=sharing&ouid=103068518904190156690&rtpof=true&sd=true
First I made a single formula to work on a single cell. It ignores semicolons and commas to calculate total words. That formula is in column F and it's:
=IF(LEN(E5)=0;0;LEN(TRIM(SUBSTITUTE(SUBSTITUTE(E5;";";" ");",";" ")))-LEN(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(E5;";";" ");",";" "));" ";""))+1
Notice I added an IF to make sure that blank cells will count as 0 words (because the +1 will be added wrongly and we need to avoid this.
Now you just need to sum up all results and we get 8 words.
What you want is to get this result with a single formula and that can be perfomed with array formulas. In cell F11 my formula is:
=SUM(IF(LEN(E5:E8)=0;0;LEN(TRIM(SUBSTITUTE(SUBSTITUTE(E5:E8;";";" ");",";" ")))-LEN(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(E5:E8;";";" ");",";" "));" ";""))+1))
You need to introduce this formula pressing CTRL+ENTER+SHIFT or it won't work!
Now you got the result in a single formula and you just need to add your conditions mentioned in your post
UPDATE: In your Google Sheets, the correct formula would be:
=ArrayFormula(IF(SUM(IF(LEN(TRIM(A3:B3))=0,0,LEN(TRIM(A3:C3))-LEN(SUBSTITUTE(A3:C3," ",""))+1))>=3,"Good","Bad"))
Please, notice Excel is not the same as Google Sheets so sometimes the formulas may be different in one of them.
I got an issue with Xlookup formula for the lookup array & return array. As the 1st one I need to manually select the range for lookup and return array, I try to use Xlookup with multiple criteria to match with the keyword instead of only matching one criteria. However, the result was appear to be different. Please help how to adjust the formula to remove the manual selecting range. Thank you.
G column is text
AE column is number
J column is text
Z column is number
W column is date
=XLOOKUP(AE3,工作表2!$Z$2:$Z$6,工作表2!$W$2:$W$6,,1)
=XLOOKUP($G3&$AE3,工作表2!$J:$J&工作表2!$Z:$Z,工作表2!$W:$W,,1)
Your sheet names showing in Chinese may be confusing some people.
I'm not aware of any syntax in Excel that allows you to concatenate columns as part of an array definition. It would be great if we could do this. The only way I know to do this is with another column and then use that for your array. You could add $J2&$Z2 to another column and then use that. If you added that to column H your xlookup() would be:
=xlookup($G3&$AE3, $H2:$H6, $W2:$W6,,1)
Here's how it looks. I showed the xlookup() functions in F9 and F10 (right aligned) and the results in G9 and G10.
I have a data file and I need to return the dates of when the value (MaxT) is greater than or equal to 30 (>=30) for 3 consecutive days.
Data File:
Date, MaxT
1872-03-01,31
1872-03-02,29
1872-03-03,37
1872-03-04,40
1872-03-05,22
1872-03-06,9
1872-03-07,28
1872-03-08,31
1872-03-09,35
1872-03-10,37
1872-03-11,44
1872-03-12,29
1872-03-13,35
1872-03-14,48
1872-03-15,33
1872-03-16,31
1872-03-17,38
1872-03-18,31
1872-03-19,42
1872-03-20,20
1872-03-21,24
1872-03-22,31
I have attempted to figure this out using the following code but, I do not think I'm even in the ballpark...
Attempted Code:
=SUMPRODUCT(--(FREQUENCY(IF(B2:B23>=30,ROW(B2:B23)),IF(B2:B23>=30,ROW(B2:B23)))=3))
I'm assuming that your data file consists of 2 columns Date and Max T. If they are delimited by commas, you need to split them to 2 different columns using Text to columns delimited by commas ,.
The Date should be in Column A and Max T in Column B.
Enter the below formula in cellC2 and drag down,
=IF(AND(B2>=30,B3>=30,B4>=30),"Consecutive Range","")
The starting of the consecutive range of values greater than 30 will be shown in the output as above. You could then use a filter of some other excel function like Index-Match to get the corresponding dates. Hope this helps.
Alright, I got it to work, but I'm not entirely sure how you would make it work without separating the formula into multiple cells.
One potential solution would be to write some of the formulas into a sheet that's in the background, place the final part of the formula in the front sheet and have it reference the "hidden" bits of the formula.
First, I wrote the data in columns... "Date" in Column A, "MaxT" in Column B.
The first part of the formula is written in cell D2:
=IF(B2>=30,B2,"")
The next part of the formula is written in cell E2:
=COUNT(D2:D4)
The last part of the formula is written in cell F2:
=IF(E2=3,A2&","&A3&","&A4,"")
The result of this formula, in column F, there are 7 cells that have three dates written in them, separated by a comma.
Note that you can make any character or string of text separate the three displayed dates by replacing the commas that are in-between the ampersand, quote text:
(&","&) can become (&"anything you want"&)
From here, auto-fill the formulas to the relevant cells.
EDIT:
One way to shorten the code is to add the COUNT formula into the last IF statement like this:
=IF(COUNT(D2:D4)=3,A9&","&A10&","&A11,"")
I do still think that the first IF statement will need to be separate from the rest of the formula, though.
EDIT #2
Here is the code in one single cell:
=IF(AND(B2>=30,B3>=30,B4>=30), A2&","&A3&","&A4,"")
Which will display three dates that are located within Column A, current row & the next two rows below it.
This code still produces 7 lines of results with the data that you've provided.
So I need some help with excel.
What I have is in Black and what I need is in Red.
I have been able to rearrange column B to match column A and have it output in E but I need it to take the values in column C and D with it. This is what I have been using in column E:
=IF(ISNA(VLOOKUP(A1,$B:$B,1,FALSE)), "Missing", A1)
Can someone please help me figure out how to bring columns C and D with column B and populate them in F and G.
Any help is much appreciated! Thanks!!
You were pretty close - Since this is a dynamic range, I would suggest using the OFFSET() function from a specific location in your spreadsheet.
So, here's the formula you could paste into cell E1 and drag across / down to get the result you want:
=IFERROR(OFFSET($A$1,MATCH($A1,$B:$B,0)-1,COLUMN(A1)),"Missing")
Basically, what you're saying is:
If I get an error in matching the value I want, print Missing:
=IFERROR(MATCH($A1,$B:$B,0),"Missing")
Move a set number of rows from cell A1 based on where the numbers match with column A:
OFFSET($A$1,MATCH($A1,$B:$B,0)-1 ...
As I drag to the right, keep referencing the next column:
OFFSET($A$1,..., column(A1))
Hope that helps explain it.
I have a spreadsheet with one column, Column "M," that has rows containing alpha numeric values like the following: 103.14 Jose Dolorez Chavez. I am not sure if there is code out there that can loop through each row of cells, cut the numerical values and paste them into an adjacent column. So At the end, I would have:
one column: 103.14 another column: Jose Dolores Chavez
Could someone help me. I'm not sure where to start. The code would need to loop through all 500 rows in column "M," find/cut the values, and paste them into column "N."
Any advice would be greatly appreciated and thank you in advance.
No, the pattern remains the same throughout: Number, followed by Employee name. – Dora 13 mins ago
You do not need VBA for this. You can easily achieve this via Text To Columns.
Highlight Column M and click on Data | Text To Columns | Delimited
Select space as delimiter and click on finish and you are done. See snapshot here
Uploading the screenshot in wikisend.com as it seems like imgur is down today.
Here's a VBA function you can use. It uses the Val function, which returns the numeric part at the beginning of a string. Just put it in a regular code module in your workbook:
Function GetNumAtBeginOfString(StringWithNum)
GetNumAtBeginOfString = Val(StringWithNum)
End Function
Then in column O put this formula (assumning your data starts in row 2):
=GetNumAtBeginOfString(M2)
And if column N put this formula:
=TRIM(SUBSTITUTE(M2,O2,""))
... and copy down.
This leaves you with the original string and two new columns. If you want you can copy and paste over the original.
EDIT: you can use this Excel formula in column O instead of the VBA function:
=MAX(IF(ISNUMBER(LEFT(M2,ROW($A$1:$A$100))*1),(LEFT(M2,ROW($A$1:$A$100))*1),0))
It's an array formula and must be entered with Ctrl-Shft-Enter