I have two cells that need to be merged into one, but the formatting needs to be updated. In one cell there are category IDs and in the other cell are subcategory IDs. None of them are formatted to have leading zeros, which isn't too big of a deal because I can just use the number format for that. The problem is that the subcategories sometimes have a letter at the end. Number format completely ignores these and just leaves them be. Is there a formula/combination of formulas I can use to get data to look like this?
Category
Subcat
Output
1
1
01-01
4
12
04-12
21
1
21-01
21
1b
21-01b
EDIT
Sorry about the previous answer. This one is correct
=ArrayFormula(IF(A2:A<>"", IF(LEN(A2:A)=1,"0"&A2:A,A2:A)&"-"&IF(REGEXMATCH(B2:B&"","^\d{1}$|^\d{1}\D")=TRUE,"0"&B2:B,B2:B),""))
WRONG (You can use this)
=ArrayFormula(IF(A2:A<>"", IF(LEN(A2:A)=1,"0"&A2:A,A2:A)&"-"&IF(LEN(B2:B)=1,"0"&B2:B,B2:B),""))
try:
=INDEX(IFNA(TEXT(A1:A, "00-")&
TEXT(REGEXEXTRACT(B1:B&"", "\d+"), "00")&
IFERROR(REGEXEXTRACT(B1:B, "\D+"))))
Try:
=IF(ISNUMBER(A2), TEXT(A2,"00"), TEXT(LEFT(A2,LEN(A2)-1),"00")&RIGHT(A2))&"-"&IF(ISNUMBER(B2), TEXT(B2,"00"), TEXT(LEFT(B2,LEN(B2)-1),"00")&RIGHT(B2))
And just paste it in every cell in column C
Related
In cell C5, I have a date with dashes ---> 01-31-2013
I just need to remove the dashes, extract only the first 4 digits in the date (in this case, 0131), and append 'Efisd' at the BEGINNING of the string.
So, the end result should look like this ---> Efisd0131
So far, I've been able to remove the dashes, and extract the first 4 digits of the date. But, I can't seem to put append 'Efisd' to the beginning and put it all together into one formula.
Does anyone know how to do this? Thanks for your help.
Here's the sample spreadsheet that you can edit
From just the input date you can get it done with this:
="Efisd"&left(substitute(B5,"-",""),4)
It substitutes the dashes for blanks, gets the left 4 characters, and ads Efisd to the front.
If anyone wants the arrayformula version of this, here it is below. Put formula in very top cell in column, edit the header in between quotes, and change cell values to fit your spreadsheet.
={"Your Header";arrayformula(iferror(if(len(M2:M),"Efisd"&left(substitute(M2:M,"-",""),4),""),))}
I got into a bit of problem. I have data like this
Date Repeat
7-Oct-2018 1
8-Oct-2018 1
9-Oct-2018 2
10-Oct-2018 2
11-Oct-2018 3
12-Oct-2018 2
13-Oct-2018 1
Now the result i want is a column where the date is repeated as per the repeat numbers, like this.
Result
7-Oct-2018
8-Oct-2018
9-Oct-2018
9-Oct-2018
10-Oct-2018
10-Oct-2018
11-Oct-2018
11-Oct-2018
11-Oct-2018
12-Oct-2018
12-Oct-2018
13-Oct-2018
So how can i get this result. Please do help
I tried to think of it for own study. For example, how about this sample formula? I think that there might be simpler formulas. So please think of this as one of them. When you use this, please put the following formula to a cell.
=TRANSPOSE(SPLIT(JOIN(",",ARRAYFORMULA(REPT(A2:A8&",",B2:B8))),","))
This formula supposes that the values of Date and Repeat are put in A2:A8 and B2:B8, respectively.
Show repeatedly Date using REPT(). At this time, , is used as a delimiter.
Join each cell with , using JOIN().
Split the cell with , using SPLIT().
Transpose the cells using TRANSPOSE().
I think that you can also use CONCATENATE() and TEXTJOIN() for joining cells.
References:
REPT
JOIN
SPLIT
TRANSPOSE
CONCATENATE
TEXTJOIN
Greeting
I'm sorry for the intrusion, but I have a question that seems no one asked before.
I want to know if there is a formula for Conditional Formatting in spreadsheet to highlight certain cell, if a duplicate of certain text came in sequence in the same row.
A B C D E F
26 27 28 29 30
deni V X X V X
In the above example, I want to highlight the name "deni" when there are 2 "X"'s that came in sequence, which was the case at the 27 and 28 date.
Is there any formula for this? I have tried =OR(B2=C2,C2=D2) but it only works for 2 cells (B2&C2) with any text (not the "X" only).
Here is an example of the spreadsheet
PS: i'm sorry, i used excel tag before. but i need this formula to work in google spreadsheet. my bad, sorry
Conclusion: My Question have been answered, i used both formulas from I'-'I and Tom Sharpe and it worked like a charm. Many thanks to the people that responded My Question :)
=SUMPRODUCT((D2:AG2="x")*(E2:AH2="x"))
Apply to:
A2:A
Also
=countifs(D2:AG2,"x",E2:AH2,"x")
If you want to check if there is a duplicate text (not the "X"), you can use:
=IF(SUM(COUNTIF(D2:AH2,D2:AH2))>COUNTA(D2:AH2),1,0)
1 means true, 0 means false. This is because if there is at least one duplicate text, the sum of all the texts' appearance times will greater than the count of all the texts (if not they will be equal).
To be highlight a certain cell, here is deni, you can use Conditional Formatting -> Highlight Cell Rules -> More Rules -> use a formula to datemine which cells to format, and then paste the formula above in the cell.
Step1:Select the range of cells you want to apply conditional formatting to.
Step2:On the Home tab, click Conditional Formatting.
Step3:Point to Highlight Cells Rules, Go on More Rules...
Step4:Choose Use a formula... Paste the following one,
=SUMPRODUCT(COUNTIF(C3:G3,C3:G3)-1)>0
Step5:Format how you want to highlight
Step6:Click OK and Apply
Hope this helps you.
Note: Change the range in the formula as per your data.
I have a large list of people where each person has a line like this.
Bill Gates, IT Manager, Microsoft, <https://www.linkedin.com/in/williamhgates>
I want to extract the company name in a specific cell. In this example, it would be Microsoft, which is between the second and third delimiters (in this case, the delimiter is ", "). How can I do this?
Right now I'm using the split method (=SPLIT(A2, ", ",false)). But it gives me four different cells with information. I would like a command only to output the company in one cell. Can anyone help? I have tried different things, but I can't seem to find anything that works.
Maybe some regex can do it, but I'm not into regex.
Short answer
Use INDEX and SPLIT to get the value between two separators. Example
=INDEX(SPLIT(A1,", ",FALSE),2)
Explation
SPLIT returns an 1 x n array.
The first argument of INDEX could be a range or an array.
The second and third arguments of INDEX are optional. If the first parameter is an array that has only one row or one column, it will assume that the second argument corresponds to the larger side of the array, so there is no need to use the third argument.
A bit nasty, but this formula works, assuming data in cell D3.
=MID(D3,FIND(",",D3,FIND(",",D3)+1)+2,FIND(",",D3,FIND(",",D3,FIND(",",D3)+1)+1)-FIND(",",D3,FIND(",",D3)+1)-2)
Broken down, this is what it does:
Take the Mid point of D3 =MID(D3
starting two characters after the 2nd comma FIND(",",D3,FIND(",",D3)+1)+2
and the number of characters between the 2nd and 3rd comma, excluding spaces FIND(",",D3,FIND(",",D3,FIND(",",D3)+1)+1)-FIND(",",D3,FIND(",",D3)+1)-2)
I'll add my favourite ArratFormula, which you could use to expand list automatically without draggind formula down. Assumptions:
you have list with data in range "A1:A20"
all data have same sintax "...,Company Name, <..."
In this case you could use Arrayformula, pasted in cell B1:
=ArrayFormula(REGEXEXTRACT(A1:A20,", ([^,]+), <"))
If your data doest's always look like "...,Company Name, <..." or you wish to get different ounput, use this formula in cell B1:
=QUERY(QUERY(TRANSPOSE(SPLIT(JOIN(", ",A1:A20),", ",0)),"offset 2"),"skipping 4")
in this formula:
change 2 in offset 2 to 0, 1, 2, 3 to get name, position, company, link
in skipping 4 4 is a number of items.
Number of items can be counted by formula:
=len(A1)-len(SUBSTITUTE(A1,",",""))+1
and final formula is:
=QUERY(QUERY(TRANSPOSE(SPLIT(JOIN(", ",A1:A20),", ",0)),"offset 2"),
"skipping "&len(A1)-len(SUBSTITUTE(A1,",",""))+1)
Why does =SPLIT("1,2-5,4", ",")
equal
1 42040 4
instead of
1 2-5 4 ?
I have all of the cells formatted at plain text.
Regextract should give you the desired output. Try:
=ArrayFormula(regexextract("1,2-5,4", {"^(\d+),",",(.+),",",(\d+)$"}))
To complement JPV's answer.
You can use:
=REGEXEXTRACT(A1,"(.*?),(.*?),(.*)")
which is "hard-coded" to splitting exactly 3 elements (as JPV's is). To give more flexibility, you can use something like:
=REGEXEXTRACT(A1&REPT(",",10),REPT("(.*?),",10))
which is limited to a maximum of 10 elements (that number can be changed to suit). However, it will output an array that is always that maximum number of elements long (padded out with blank cells). You could use QUERY or FILTER to filter out those blank cells - the formula will become a little convoluted.
Alternatively, you can "code" your string such that automatic date coercion is avoided, and then "uncode" it after the SPLIT:
=ArrayFormula(SUBSTITUTE(SPLIT(SUBSTITUTE(A1,"-","x"),","),"x","-"))
With 1,2-5,4 in a cell this can be split as required with Data > Split text into columns... .