I am trying to split this number that is in one cell of its own in I2: 0000320193-20-000096
However, when I use the formula '=split(I2, "-")', it gives me three cells with the following: "320193" , "20" , "96".
I need the zeroes behind each number to stay with each number, I just need the hyphens to be removed and each separate number to be in their own cells.
I have tried '=split(I2, "'-")'; however, this does not work either.
In addition, all the cells are formatted to be "plain text."
I can make it work if I use the "split by column" tool; however, it's tedious and removes the surrounding text to I2, which I need.
How can I change this formula to keep the zeroes in front of each number?
Thanks!
Try this:
=ARRAYFORMULA(SUBSTITUTE(SPLIT("'"&I2&"'", "-"), "'", ""))
This will append apostrophe in the beginning and end of cell I2 to avoid auto formatting and since SPLIT return an array, we need ARRAYFORMULA to apply the SUBSTITUTE to all array element.
Output:
References:
SUBSTITUTE
ARRAYFORMULA
SPLIT
try:
=INDEX(REGEXEXTRACT(SPLIT("'"&SUBSTITUTE(A1, "-", "'-'")&"'", "-"), "(.*)'"))
Use regexextract(), like this:
=regexextract(I2, "(\d+)-(\d+)-(\d+)")
Related
So, I have a formula graciously shared by someone here that works amazing in highlighting cells in a column that contains letters from K to Z, excluding RR. Here it is below...
=REGEXMATCH(E5:E,"[K-Z]")*(REGEXMATCH(E5:E,"RR")=FALSE)
But, I'm trying to accomplish the same thing with an IF formula (not conditional formatting), where if a cell in column E contains a letter from K-Z, it will display the green checkbox, and if not, display the red down arrow. I'm not sure exactly how to exclude RR again in the equation. Here's the formula I'm trying to get to work...
={"OL";ARRAYFORMULA(IF(E5:E="",,if(REGEXMATCH(E5:E,"K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z"),"✅","🔻")))}
The formula works except it includes cells containing RR, I guess because R is in there? But I want to exclude cells containing RR.
Here's a Google Sheet that contains the formula I'm currently using.
Thanks for any help you can provide.
I left a new sheet ("Erik Help") with a formula in B1 that somewhat follows the form of your original formula there, since that seems to be something you understand. All I did was add another outer IF to rule out instances of "RR" up front:
={"OL";ARRAYFORMULA(IF(A2:A="",,IF(A2:A="RR","🔻",IF(REGEXMATCH(A2:A,"[K-Z]"),"✅","🔻"))))}
use:
={"OL"; INDEX(IF(
REGEXMATCH(E5:E,"[K-Z]")*(REGEXMATCH(E5:E,"RR")=FALSE),
"✅", "🔻"))}
i have a sheet along with this question,the formula used in column E2 is : if(and(d2>=0,d2<=2),5. So when the column is blank it gives the value 5 My query is can we left the "E" column blank when there is no value in "D". ??? 5 must displayed only if there score between 0 & 2.
https://docs.google.com/spreadsheets/d/1XpdXcWDReB8TGvZ6ocALAilVPLDKzZXvd90YhNos0Io/edit?usp=sharing
Iker. I've added a sheet with two approaches.
If you want to drag the formula, just set an initial IF that rules out blanks like this:
=if(D2="","",if(and(D2>=0,D2<=2),5,if(and(D2>=3,D2<=4),0)))
I placed this into my sheet, E2, and dragged down as you were doing.
However, this is a great example of where array formulas are handy. An array formula can "run" your whole column from just one cell. I placed the following array formula into cell I1 of my sheet:
=ArrayFormula({"POINT";IF(H2:H="","",IF((H2:H>=0)*(H2:H<=2),5,IF((H2:H>=3)*(H2:H<=4),0,"")))})
First, keep in mind that array formulas must have unused space below them in order to fill in results. If you type anything manually below an array formula, inside the range it is trying to work on, you'll get an error. If you do want to put other data below an array formula, just limit the range in the array formula (e.g., change every H2:H to H2:H6 or whatever the end of that data range might be).
ArrayFormula() tells Google Sheets to apply this formula to the entire range in the formula. Since the range in the formula is H2:H, every cell in I2:I will be "reserved" by this array formula.
The curly brackets {} allow us to build another custom array inside the first array.
Since I want a header in I1, I put that header name first in the curly brackets. The semicolon tells the array to put the next part underneath.
The next part may look strange, but it's basically the same as your original formula, except that AND(), OR(), etc., don't work inside arrays. So the logical operators inside arrays are different. In this case, an asterisk * means AND.
The same conditions from your original formula are used here. And if it meets none of those criteria (for instance, if someone entered -1 or 7 or M somewhere in Column H, the last part of the last IF would just assign a blank.
You can use an added IF to your formula
=IF(D2="","", if(and(D2>=0,D2<=2),5,if(and(D2>=3,D2<=4),0)))
I'd like to drag the formula
=if(and(AHTpivot!$A1=statusSheet!$A1, AHTpivot!$B1="wrap-up"),AHTpivot!$C1, "")
right to adjacent columns about 1,000 times. I only want statusSheet!$A1 to increase, and it needs to increase in rows instead of columns.
For instance, if the formula is in A1, and I drag it to B1, it should be in cell B2. [?]
=if(and(AHTpivot!$A1=statusSheet!$A2, AHTpivot!$B1="wrap-up"),AHTpivot!$C1, "")
Maybe:
=if(and(AHTPivot!$A1=indirect("StatusSheet!$A"&Column()),AHTPivot!$B1="wrap-up"),AHTPivot!$C1, "")
You could also use an array formula if you don't want to drag the formula.
=ARRAYFORMULA(IF(
(AHTpivot!$A1=INDIRECT("statusSheet!$A"&COLUMN(A1:AAA1))
* (AHTpivot!$B1="wrap-up")
,AHTpivot!$C1, "")
The * acts as an and.
Change AAA1 to the column reference you desire. Or, change to COLUMN(A1:1) if you want to go to the end of the sheet.
Credit to pnuts for the INDIRECT idea. :)
I would like to fill a column cell with an "x" if a range further across that row has any text in it.
Sample spreadsheet
'A' column would fill with "x" if there are any values in it's row from 'C:F' and stay blank if the row (in that range) is blank.
I've tried variations of =IF =ISBLANK for this.
=IF(ISBLANK(C:F),"","x") still placed an X even if the row was blank.
ISBLANK works for a single cell but we do have an alternative:
=if(countblank(C2:F2)=4,"","x")
In addition to pnuts' contribution, an array-enabled solution could be
=ArrayFormula(if(countif(if(C2:F20<>"", row(2:20)), row(2:20)), "x",))
An alternative to the above
=if(LEN(CONCATENATE(A2:F2))>0,"X","")
This grabs all inputs across the row, concatenates them together in one string, counts the length of that combined string, and returns a "X" if it's greater than zero.
This has the advantage that it works if you add more headers (if you extend the range).
The disadvantage is that it would also count whitespaces
lets say I have a column of URLs in A, I would like to have a script that would insert a formula into the next column over so that it would look like the attached image.
I know how to insert a formula into a single cell through script, but unsure of how to get it down the entire column relative to the cell to the left.
You can use array formula like this:
=ARRAYFORMULA(IMAGE(A2:A))
or you can wrap it in an if statement to only pull in the images where there is a valid url present with:
=ARRAYFORMULA(IF(ISURL(A2:A),IMAGE(A2:A),))
ArrayFormula is good solution. I prefer limiting the used range by it's size. If your data has no blanks, you could also use this formula:
=ARRAYFORMULA(IMAGE(OFFSET(A2,,,COUNTA(A:A)))
Paste it in cell B2.
offset + counta will give range A2:A6 in your case.