How not to show 0 with IF - excel

This is my excel function. I don't know how to change the IF sentance to not include 0's if they are in a certian column.
Tried nesting them like in programming languages but it did not work.
=AG2
& "-"
& D2
& IF(LEN(F2)<=2;F2;"")
& IF(F2="0";"";)
& IF(F2="3XL";"XXXL";)
& IF(F2="4XL";"XXXXL";)
& IF(F2="5XL";"XXXXXL";)
& IF(F2="6XL";"XXXXXXL";)
& IF(F2="XXL";"XXL";"")
I don't seem to know how to post a cleaner version of the formula.
unedited:
=AG2 & "-" & D2 & IF(LEN(F2)<=2;F2;"") & IF(F2="0";"";) & IF(F2="3XL";"XXXL";) & IF(F2="4XL";"XXXXL";) & IF(F2="5XL";"XXXXXL";) & IF(F2="6XL";"XXXXXXL";) & IF(F2="XXL";"XXL";"")

The condition for the length of F2 needs to be nested into the condition to see if F2 is zero.
=AG2
&"-"
&D2
&IF(F2="0"; ""; IF(LEN(F2)<=2; F2; ""))
&IF(F2="3XL";"XXXL";)
&IF(F2="4XL";"XXXXL";)
&IF(F2="5XL";"XXXXXL";)
&IF(F2="6XL";"XXXXXXL";)
&IF(F2="XXL";"XXL";"")

Try the following
=AG2 & "-" & D2 & IF(F2=0; ""; IF(AND(IFERROR(FIND("XL"; UPPER(F2)); FALSE); ISNUMBER(VALUE(TRIM(SUBSTITUTE(UPPER(F2); "XL"; ""))))); REPT("X"; VALUE(TRIM(SUBSTITUTE(UPPER(F2); "XL"; ""))))&"L"; F2))
To break this down we can look at it in chunks. The first part is obvious
AG2 & "-" & D2
Takes the values from Cells AG2 and D2 and combines them with a - separator.
The next part produces the output from cell F2
IF(F2=0; ";
This tests whether cell F2 is equal to 0 and if so returns an empty string.
The next condition we test for if F2 contains an XL and if so is there a number in the cell as well.
IFERROR(FIND("XL"; UPPER(F2)); FALSE)
Tests if F2 has "XL" in the value
ISNUMBER(VALUE(TRIM(SUBSTITUTE(UPPER(F2); "XL"; ""))))
Tests whether there is a number included as well
If both the conditions above returns True then the formula repeats the letter "X" the number of times of the number in cell F2 and combines it with an "L" on the end
REPT("X"; VALUE(TRIM(SUBSTITUTE(UPPER(F2); "XL"; ""))))&"L"
e.g. this will convert
2xl -> XXL
3xl -> XXXL
4xl -> XXXXL
5xl -> XXXXXL
6XL -> XXXXXXL
7XL -> XXXXXXXL
etc.
For anything else (e.g. "", S, M, L, XL, XXL etc.) it will return those values unmodified. This should cover all of your examples above and more (if needed)

Related

Subtract string in one cell from another which are comma separated in excel [duplicate]

This question already has an answer here:
Subtracting a comma separated string from another one in Excel [closed]
(1 answer)
Closed 2 years ago.
How can I subtract a comma separated string from another one in Excel?
I want to subtract, A1 and A2 from A3 .
A1 - Wed,Thu
A2- Sun, Mon
A3- Mon,Tue,Wed,Thu,Fri,Sat,Sun
A4- Tue,Fri,Sat
I tried the following :-
=IF(ISERROR(SEARCH(A1,A3,1)),A3,RIGHT(A3,LEN(A3)-LEN(A1)))
But the output is not as what I wanted.
PS :- The A4 answer is the desired answer and not the answer I got after writing the above formula.
I'm assuming these values are delimited by comma-space. If not then adjust the formula accordingly (or use a double substitute to get rid of spaces before changing commas to tags).
In A4 try:
=TEXTJOIN(", ",1,FILTERXML(SUBSTITUTE("<t><s>"&A3&", "&A2&", "&A1&"</s></t>",", ","</s><s>"),"//s[not(following::*=. or preceding::*=.)]"))
Enter through CtrlShiftEnter
If FILTERXML does spark your interest, then have a look here for more possibilities.
Consider the following User Defined Function:
Option Explicit
Public Function RemoveItems(BigString As String, LittleString As String) As String
Dim Good As Boolean, L, B, arrB, arrL
Application.Volatile
arrB = Split(Replace(BigString, " ", ""), ",")
If InStr(LittleString, ",") = 0 Then
For Each B In arrB
If LittleString = B Then
Else
RemoveItems = RemoveItems & "," & B
End If
Next B
Else
arrL = Split(Replace(LittleString, " ", ""), ",")
For Each B In arrB
Good = True
For Each L In arrL
If L = B Then Good = False
Next L
If Good Then RemoveItems = RemoveItems & "," & B
Next B
End If
If RemoveItems <> "" Then RemoveItems = Mid(RemoveItems, 2)
End Function
It will remove items from the first comma-separated-string that appear in the second comma-separated-string. for example:
In your example, you would nest the calls:
=RemoveItems(RemoveItems(A3,A1),A2)
NOTES:
this version will accept a single item as well as a LettleString
this version removes spaces from the strings

Convert 5 cells with 1s and 0s into a single array like {1,0,0,1,1} in Excel

Alright, in excel I'm converting a 5 bit binary code into a single array in the form of a string. Cells D62, D64, D68, D70, and D72 all have either a 1 or a 0, and I'm requesting help to convert these cells with numbers in them into an array by using a formula. I need the output to cell D59.
=IF(ARRAY(D62:D70)={1,1,1,0,0},1,0)
something like that
To change the 5 cells values to a 5 bit binary letter just concatenate:
=CHAR(BIN2DEC(A1&A2&A3&A4&A5)+64)
If one has CONCAT:
=CHAR(BIN2DEC(CONCAT(A1:A5))+64)
In D59 enter:
="{" & D62 & "," & D64 & "," & D68 & "," & D70 & "," & D72 & "}"

Feedback base on cell value

How do I carry out the function? I'm sure this is beyond nested if.
Feedback base on value in column G,J & M.
Value to compare with number text in red.
Feedback generated in column N for MX-IE21001-1, MX-IE21001-2 & MX-IE21001-3 which have exceeded the range, in red text.
Given the scenario when MX-IE21001-3 cumulative settlement value is -50, MX-IE21001-2 value is -8 & MX-IE21001-1 value is -2. Column N will automate"Exceeded PDL # MX-IE21001-3 & Exceeded AL # MX-IE21001-2.
You can do this with a set of nested ifs concatenated together. The test for MX-IE21001-1 would look something like this:
= IF(N13<$G$19,"Exceeded PDL # MX-IE21001-1",
IF(N13<$F$19,"Exceeded AL # MX-IE21001-1",""))
Let's call that Test1. You can do the other two tests, Test2 and Test3, analogously.
Then you can string them together like so
= Test3 & " " & Test2 & " " & Test1

formula for difference between start & end time includes milliseconds in Excel

I want to find the time difference between start & end time using Excel
my Data :
A1 = 16:00:03:38
B2 = 16:14:13:58
which is in pattern of "h:mm:ss:ms" h=hours,mm=minutes,ss=seconds,ms=milliseconds.
am using like this =B2-A1 but it not giving result instead of it giving output like this " #VALUE! "
if i change like this
A1 = 16:00:03.38
B2 = 16:14:13.58
answer is = 00:14:10:20
the answer is giving perfect
but i don't want to change : to .
is it possible to take difference between two time's as per my requirements.
Let the formula do the conversion:
=TIMEVALUE(LEFT(B2,8) & "." & RIGHT(B2,2))-TIMEVALUE(LEFT(A1,8) & "." & RIGHT(A1,2))

Using SUMIF to Evaluate two rows of Data and output anwser to two specific cells

My data looks like this:
1 cs
2 ea
1 cs
1 cs
1 cs
1 cs
11 cs
There are numbers in the left column and quantity’s in the right
"CS" = Cases and "EA" = Each.
I have used this formula for each result Separately:
(CELLB8)=SUMIF(E2:E4,"CS",D2:D4)
(CELLC8)==SUMIF(E2:E4,"EA",D2:D4)
I need to combined these two "if" statement into one, but still have the output for "cases" and "each" in their Cells.
I don't know if this is even possible. I have looked everywhere for answer.
Thank you!
Your question is not that clear but if you want to visualize your answer in one cell next to each other you can use & for this:
=SUMIF(E2:E4,"CS",D2:D4) & "CS " & SUMIF(E2:E4,"EA",D2:D4) & "EA"
A little bit more detail as follows:
In the picture,
cell (A9) = cumulation of "CS":
=SUMIF(B2:B8,"CS",A2:A8) & " CS "
cell (B9) = cumulation of "EA":
=SUMIF(B2:B8,"EA",A2:A8) & " EA"
cell (A10) = combines cumulations:
=SUMIF(B2:B8,"CS",A2:A8) & " CS & " & SUMIF(B2:B8,"EA",A2:A8) & " EA"

Resources