Basic IF Statement question -probably right in front of me - excel

Sorry i know this is super basic but i didn't know where else to ask and i really feel like the answer is right in front of me...
I have a spreadsheet which im going to use to log PAT test results. When i select the test type from a drop down it changes the standards and thresholds in the bit below and will tell me if each test passes or fails. It uses several vlookups and relative references - so far no VBA. Looking at this photo. What I'm trying to do is get the formula in cell I13 to read the symbol in F13 and use that in the formula rather than typing the symbol directly into the formula as its going to change when i change the Class Type option.
So far ive gotten to this (has a blank IF to start with to keep it neat:
=IF(H13="","",IF((H13&F13&(VALUE(G13))),"PASS","FAIL"))
The bit in bold is where the issue is. When i run the evaluate formula it boils the bold bit down to "0.01>2" which is correct however it then wont read that in the larger IF statement - i think its the quotation marks. So i think it needs another function to allow the IF statement to read that as the logical test rather than a text string.
I've tried VALUE, FORMULATEXT, NUMBERTEXT, all the ones that might be close to what I'm trying to do but 100% stumped now. Always bring sup the #VALUE Error.
Appreciate any advice? TIA

There is no built-in function for that. You need either a VBA function or the old EVALUATE XLM function (which you can't use directly in a cell, it has to be in a defined name). Sample UDF:
Function EvaluateFormulaString(FormulaString as string)
EvaluateFormulaString = application.evaluate(formulastring)
End Function
then your formula would become:
=IF(H13="","",IF(EvaluateFormulaString(H13&F13&(VALUE(G13))),"PASS","FAIL"))

Related

Google sheets, how do I get regexmatch to find a text string in a list?

I am new here, I have tried search for this answer and I can't find the same question
I am a totally self taught spreadsheet-maker, so if I have done some weird stuff - Please don't judge too harshly!
So I am using REGEXMATCH, and it just doesn't seem to be working like it usually does, and I can't work out why.
=IF($A13="","",(IF(REGEXMATCH({$L$13:$L$18},$A13),"YES","NO")))
I have made a workbook example to show the dilemma-
https://docs.google.com/spreadsheets/d/1paNG9Q-AciYbIR3HSgW7vxqNJmJBexgpm2lkLn32PN8/edit?usp=sharing
I want each line to tell me if its CODE-ID is in a list of items. I am pretty sure I had this working at some point, but I can't remember what I have changed. The regexmatch seems to just be picking up whether the code is in the first cell of the list.
Can anyone tell me what I have done wrong? I want the YES/NO column to change as I add new CODE-IDs to the list.
The weird thing is, I have got other cells to work by breaking the code right down to the basic regexmatch formula and building it up again, but it wont replicate when I copy it to another line. I don't know how to show that in this example because it isn't working here.
Let me know if this makes sense,
Thank you kindly,
Ellie
use in I13:
=INDEX(IF(A13:A="",,IF(ISNUMBER(MATCH(A13:A, L13:L18, 0)), "YES", "NO")))
You can use this array formula. No need to drag down to each cell.
=ArrayFormula(ISNUMBER(MATCH(A13:A18,L13:L18,0)))

Evaluate long string (>255 characters) as array

So I quite often find myself doing tasks on Excel which involve evaluating a text string as an array. Generally speaking I just use this:
Function EVAL(Ref As String)
EVAL = Evaluate(Ref)
End Function
So the formula will be, for example:
=EVAL("{"&CHAR(34)&SUBSTITUTE(TEXTJOIN(";",TRUE,MID(Index[Industries],2,LEN(Index[Industries])-2)),";",CHAR(34)&";"&CHAR(34))&CHAR(34)&"}")
The cells in this example will have contents like:
;Automotive;Rail;Energy;
;Automotive;Rail;
;Energy;
;Automotive;Aerospace;
(As it happens this is the precise problem I'm stuck on right now, though it has come up in different ways in the past.)
This has worked for me in the past, but I've been running into difficulties lately.
I have come to the conclusion it isn't working because application.evaluate, it turns out, has a character limit of 255. I've seen examples of VBA tricks to bypass this for text strings that are formulas rather than arrays, but copy-pasting those they don't seem to work for when I'm using it to interpret a text string as an array rather than as a formula.
Is there some trick to get this to work? (Or, indeed, is there some alternative method to achieve this altogether?)
Right, as per my comments, if you are using ms365, you could avoid your workbook to be xlsm just because you need to split values into an array. Make use of what is available with native functions, for example:
Formula in C2:
=TEXTSPLIT(CONCAT(A1:A4),,";",1)
Formula in D2:
=FILTERXML("<t><s>"&SUBSTITUTE(CONCAT(A1:A4),";","</s><s>")&"</s></t>","//s[node()]")
Note 1: As per time of writing you'd need to enable the BETA-channel to gain access to TEXTSPLIT(), and if I recall correctly your version (2203) is allowed to start using this function. Just google how to get access and update your Excel.
Both options can obviously be nested inside the UNIQUE() function.
Note 2: If at any point CONCAT()'s limits are reached (32767 characters, thanks #ScottCraner), maybe you can avoid using that with help of the lambda's helper function REDUCE():
=TEXTSPLIT(REDUCE("",A1:A4,LAMBDA(a,b,a&b)),,";",1)
Note 3: In case you can't update your Excel just yet, and you wonder how to use FILTERXML(), don't mind me refering you to another post I wrote a while back here.

Keep same value of all merged cells

I don't know why every time I fall in love with a program because I found it very useful at first use, but I end up always struggling of its stupidity after a depth use.
So, my journey begins with the excel function "Merge & Center" that warns me that it will only keep the top left value and delete the others, which is very stupid because I can no longer drag a function in a cell to the others, did no one in this planet suggested that it will be way easier to keep the same value in each merged cells or to put at least a simple checkbox to give the user the option to choose between the two outcomes.
Ok, before I come to this forum I did some research, found a lot of VBA codes, tricks, methods but none gave me the satisfaction that I'm looking for, I concluded that it's impossible to merge and keep values in cells, so can someone please explain to me why Microsoft didn't think of that?
Here is a simple example of what I'm looking for:
enter image description here
As you came to understand, merged cells are Excel's and VBA's worst nightmares! Avoid them (since they also make for terrible datastructures) if you can.
If you must use them and you need a function you can drag down, you'll need to make sure you create a mechanic that can skip certain rows. INDEX() is able to retrieve values with a 2nd parameter that tells the function which row you would like from a given array. If we make sure that this 2nd parameter has a steady incline we can still retrieve the correct values:
Formula in C1:
=INDEX(A:A,ROW()-1-MOD(ROW()-1,3)+1)&B1
After searching all over the internet, I didn't find the perfect solution, so I started learning VBA and I made this beautiful function, it detects if cells are merged or not and if so then it returns the top cell value.
Function Merg(CellRef As Range) As String
Dim MainCell As String
If CellRef.MergeCells Then
MainCell = Left(CellRef.MergeArea.Address, InStr(1,CellRef.MergeArea.Address, ":") - 1)
Else
MainCell = CellRef.Address
End If
Merg = Range(MainCell).Value
End Function
I don't know how to display the code properly on Stackoverflow. It's always a nightmare for me to understand the mechanics, you can visit my same thread on Microsoft Forum.

MATCH function on Excel returns error

For some reason the MATCH function on excel returns an error.
Unfortunately I cannot share the data in order to replicate the problem but I was wondering if someone more experienced than I am could possibly find a small error in my code or something that I missed.
I used the functions according to these directions and I also I tried a solution here but neither source helped much.
=INDEX(IB_RAW!A2:L301,MATCH(1,(IB_RAW!$B:$B=IB!P10)*(IB_RAW!$D:$D=IB!A9)*(IB_RAW!$C:$C=IB!Q9)*(IB_RAW!$L:$L=IB!P7),0),IB_RAW!$J:$J)
I will try to describe the data as best as I can:
IB: The sheet where I want to show the extracted value
IB_RAW: The sheet where I get the information from
A2:L301: The whole dataset that I am using to look for the arguments
(in IB_RAW)
J: The value I want to extract (in IB_RAW)
The issue is with the MATCH function, as it returns #N/A, I've used the Show Calculation Steps... option to see where the problem is,
So for
(IB_RAW!$B:$B=IB!P10) returns TRUE
(IB_RAW!$D:$D=IB!A9) returns FALSE
(IB_RAW!$C:$C=IB!Q9) returns TRUE
(IB_RAW!$L:$L=IB!P7) returns TRUE
Therefore MATCH(1,0,0) but this returns #N/A instead.
Ok, The solution was from this detailed guide. It actually explains that you have to press Ctrl+Shift+Enter to activate the function and also I had to change the line of code a bit.
Hopefully this will be helpful to someone who wants to do the same thing like I did.
=INDEX(IB_RAW!I2:I301,MATCH(1,(IB_RAW!B2:B301=IB!P10)*(IB_RAW!D2:D301=IB!A9)*(IB_RAW!C2:C301=IB!Q9)*(IB_RAW!L2:L301=IB!P7),0))

Using trim function on table references

I'm attempting to aggregate from an imported data source in excel. I have 2 combo boxes that specify conditions for a sumifs function (selected using offsets).
Where I struggle is that the data doesn't seem to match unless I use a trim function (I tested this on by adding a column to the data table).
The following formula always returns 0
=SUMIFS(Table_ExternalData_1[RedFlag],Table_ExternalData_1[RAGSTATUS],"=trim("&ReconAggregation!$A4&")",Table_ExternalData_1[ClientDescription],"=trim("&OFFSET(Lists!$A$1,Lists!$B$1,0)&")", Table_ExternalData_1[AgencyDescription],"=trim("&OFFSET(Lists!$C$1,Lists!$D$1,0)&")")
when I add the trims
=SUMIFS(Table_ExternalData_1[RedFlag],trim(Table_ExternalData_1[RAGSTATUS]),"=trim("&ReconAggregation!$A4&")",trim(Table_ExternalData_1[ClientDescription]),"=trim("&OFFSET(Lists!$A$1,Lists!$B$1,0)&")", trim(Table_ExternalData_1[AgencyDescription]),"=trim("&OFFSET(Lists!$C$1,Lists!$D$1,0)&")")
it tells me that I have a formula error. Any idea why? Is there a better way to do this?
Cheers,
G
it tells me that I have a formula error
Maybe there's problem with your "
=SUMIFS(Table_ExternalData_1[RedFlag],trim(Table_ExternalData_1[RAGSTATUS]),"=trim('&ReconAggregation!$A4&')",trim(Table_ExternalData_1[ClientDescription]),"=trim('&OFFSET(Lists!$A$1,Lists!$B$1,0)&')", trim(Table_ExternalData_1[AgencyDescription]),"=trim('&OFFSET(Lists!$C$1,Lists!$D$1,0)&')")
As It happens, the "=" were not required on the right hand side. This was found through trial and error. Still unsure as to why the trim function on the left prompted an error, but with additional cleansing of the source data it wasn't required. Thanks all for your input.

Resources