=IF(OR(AND(A11="3061 - Mexico"),AND(A11="3062 - Brazil")), "Mandatory","Optional")
is already working, however, if I put it in range
=IF(OR(AND(**A11:A199**="3061 - Mexico"),AND(**A11:A199**="3062 - Brazil")), "Mandatory","Optional")
Please, give more information to us.
I'm putting this like anwser because is too large to put in comments. But this will be a anwser if you want to know if any cell has the values:
Try something like this:
=IF(AND(IFERROR(VLOOKUP("3061 - Mexico"; A11:A199;1;FALSE);"") <> "3061 - Mexico";IFERROR(VLOOKUP("3062 - Brazil"; A11:A199;1;FALSE);"") <> "3062 - Brazil");"Optional";"Mandatory")
If you want to know if all cells have the value you will need to do the same, but put the others possibles values inside the IF, and use OR instead the AND function (We can think a little bit more if that is the case).
Related
Since I've exhausted about every resource I could find in regards to this question, I figured it was finally time to ask this community.
I have a very large (15k+ row) dataset that I'm looking to generate a report on giving the top 25 largest values based on one of the columns, HOWEVER, there is additional criteria that needs to be considered other than just the values in one column. I have done this already with less criteria, but adding more is giving me trouble.
My (working) formula for Top N with some criteria:
{=LARGE(IF('IMPORTED DATA'!$X$4:$X$1048576 = IF('Data Cleanup'!$AX$3 = 1, "Gaming Designed", "Not Gaming Designed"), 'IMPORTED DATA'!$BH$4:$BH$1048576), ROW(A2) - ROW(A$1))}
The issue comes when I have another criteria I need to add that uses wildcard characters to distinguish the 'correct' criteria. Here is what I've come up with so far, but this just results in the COUNTIF portion always resulting in true, so not actually applying the added criteria:
{=LARGE(IF(COUNTIF('IMPORTED DATA'!$P$6:$P$1048576, IF('Data Cleanup'!$AX$3 = 1, "?????", "????")) * ('IMPORTED DATA'!$X$6:$X$1048576 = IF('Data Cleanup'!$AX$3 = 1, "Gaming Designed", "Not Gaming Designed")) * ('IMPORTED DATA'!$E$6:$E$1048576 <> "All Other (Suppressed)"), 'IMPORTED DATA'!$BH$6:$BH$1048576), ROW(A2) - ROW(A$1))}
I tried to work-around IF statements not accepting wildcard characters using the COUNTIF method but to no avail.
I understand that this is a bit of a rough question, but I'll do my best to respond to as many questions as I can to help clarify.
A couple more bits of information that may be helpful:
This is entirely based in Excel 2019, I know that FILTER would be an easy solution, but I don't have access to that in this version of excel.
The reason for using wildcards is because it was the easiest way to distinguish between the two categories to sort: above or below 100Hz. Anything under 100Hz will be 4 characters, while anything above will be 5.
I also need other data from the same row as the results, so any methods must be also applicable to MATCH criteria so that I can look up the rest of the data with the same search parameters.
its very hard to understand without seeing the data.
What i understood is that if you make a helper column in the dataset as per the criteria you want that would solve your problem.
at least thats how i am also using.
You need to create a ranking column in the data sheet.
Ranking Formula = =COUNTIFS($M$3:$M$233,">="&M3,$K$3:$K$233,K3)
with thise formula you can add as many as criteria as you want.
Index Formula = =INDEX($K$3:$K$233,MATCH(1,($K$3:$K$233=$B$1)*($N$3:$N$233=A3),0))
you need to change the columns names you want.
no need row() functions just try always to use simple sequence will work
Good luck
Ended up solving this in a very simple method thanks to Scott Craner's comment.
Since wildcards don't work in if statements, using LEN did the trick. Final formula ended up being:
{=LARGE(IF(LEN('IMPORTED DATA'!$P$6:$P$30000)=IF('Data Cleanup'!$AX$3 =1,5,4) * ('IMPORTED DATA'!$X$6:$X$30000 = IF('Data Cleanup'!$AX$3 = 1, "Gaming Designed", "Not Gaming Designed")) * ('IMPORTED DATA'!$E$6:$E$30000 <> "All Other (Suppressed)"), 'IMPORTED DATA'!$BH$6:$BH$30000), ROW(A2) - ROW(A$1))}
Thank you to everyone for your help!
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.
not sure if this can even be done, Google search has not been too helpful (mainly due to the fact its just returning how to add a prefix)
Problem:
I have one column in Excel with two comma separated values - for arguments sake, "Bill, Ted" in A1 and I'd like to add a prefix to BOTH of the names, lets just say the word "excellent"
What I have so far looks like this and yields the correct result but only for the first value, so is there a way I can define it to attach the prefix to the next value?
=CONCATENATE("excellent",A1) - "excellentBill, Ted"
So my desired result would be:
"excellentBill, excellentTed"
I'm sure its pretty straighforward but I've been trying different approaches with CONCATENATE and SUBSTITUTE and just can't seem to get the desired result. I was wondering if you can prepend a LEN FUNCTION but wondered if there is a simpler approach?
Any help is appreciated.
Thanks.
Try this. I'm finding the delimiter in the cell then building around that.
="Excellent" & left(A1, Find(",",A1))& "Excellent" & right(A1, len(A1) -Find(",",A1))
=Concat("Excellent",left(A1, Find(",",A1)),"Excellent",right(A1,len(A1) - Find(",",A1)))
First post here, so apologies if I break any etiquette. If something is missing please let me know so I can edit my post if needed.
I'm currently working on an Excel macro, which enables me to import an interactive pdf form into excel and read data that was written in the form. Most of the script I have down by finding bits and pieces all over the internet, just one specific problem I wasn't able to solve so far.
I have one text field in my pdf that I need to split in two and save the new values in two separate cells. Not a big problem so far, but the formatting may differ, depending on the entered data, so just cutting it of after e.g. a certain amount of characters won't work. Also the quality of the user input data may not be always the same (e.g. sometimes using a hyphen between both parts of the string, using an underscore or no seperator at all). Unfortunately I can't give that text field in the pdf form a strict formatting rule, as the formatting may differ. I also cannot just make to separate form fields in the pdf file for each part of the string. The ease of use is supposed to be on the pdf user's side, not on mine...
Now, what does the data look like:
ABC-1234
ABCD-0123
A1B-12A
As you can see there is not a clear pattern. Please note that as said before the hyphen may not be there or be replaced by an underscore. I added it here to show you the separation of the two sub datasets (lets call them "Data A" for everything on the left side and "Data B" for everything on the right side of the hyphen).
The good thing! I know all the potential values Data A may have. Data B is then just supposed to be stored separately in another cell. My first train of thought was to use InStr, but that may not be the most elegant solution. Data A may be one of around 130 different values, which is also frequently growing. My excel file also has a "helper sheet", in which I store some information for e.g. dropdown menus or deadlines etc. I could store a list of potential Data A candidates here as well.
So what exactly do I need? A method to look at the string, compare it to a list of substrings (Data A, e.g. using a column in my excel sheet as data source) and store that match in Cell A1. Then take that value away from the original string so only Data B remains (I can strip away any hyphens or underscores at this point) and store this value in Cell A2.
Examples:
My import data may look like this: BER1234
Compare this to my list of match candidates, which includes "BER".
Cell A1 = "BER"
Cell A2 = (string minus the match) 1234
Import data: BERA59
Match in my candidate list: BERA
A1 = "BERA"
A2 = "59"
Import data: P9CD-1009A
Match: P9CD
A1 = "P9CD"
A2 = "1009A"
etc.
I may be able to do this with a giant block of if/else and many many InStr comparisons. Problem is, whenever I need to add a new match candidate I will have to go back to coding. It would make my life way easier if I could just e.g. add the value at the bottom of my candidate list and let the macro do it's magic.
I would love to post a piece of code here of what I did so far, unfortunately I really have no idea where to start. I do not expect a ready-to-use piece of code that I can just slab in my macro with copy and paste. If I can't understand the code, I usually go for another solution. Otherwise I can't fix it myself if anything breaks and I don't really like that approach. Giving me pointers on which functions and variable types to look at would be greatly appreciated, though. Maybe I can then piece together what I think it should look like and ask for more help after that step.
My experience level: Kind of beginner, but not total beginner. I have a basic understanding of how things work, but I'm not "fluent" in any programming languages. I know what I want to do and then usually try to get it to work by piecing together different solutions I find on the internet. So far so good, this one's a bit illusive for me, though. Any help is greatly appreciated. As mentioned before, if anything is missing or unclear, I'll gladly try to update this post.
With the suggestions I somewhat got it to work with this:
Dim wb As Workbook: Set wb = ThisWorkbook
Dim LastRow As Long
Dim x As Integer
Dim Remover As String
Dim CatNo As String
Dim Matches As Integer
With Sheets("MenuData")
LastRow = .Range("o" & .Rows.Count).End(xlUp).Row
End With
LastRow = LastRow - 4
Matches = 0
For x = 1 To LastRow
If InStr(AlbumCode1, wb.Sheets("MenuData").Range("O" & x + 4).Value) <> 0 Then
Matches = Matches + 1
Range(ColCatalog & (ImportCell.Row)).Value = wb.Sheets("MenuData").Range("O" & x + 4).Value
Remover = wb.Sheets("MenuData").Range("O" & x + 4).Value
CatNo = Replace(AlbumCode1, Remover, "")
Range(ColCatNo & (ImportCell.Row)).Value = CatNo
End If
Next
MsgBox Matches & (" Matches")
What I do is count the rows and substract 4, because my candidate list starts on row 4. Then do the loop for each x. I have declared all the Colxxx variables as Const at the very beginning of the macro. ImportCell is also declared somewhere else and working as intended for the rest of the data I import. My "Remover" is just set to the value of the match and then gets used to strip it away from the original string that is stored in AlbumCode1 (declared also at the beginning of the macro). Probably not strictly neccessary to do it this way.
So far it works. My candidates may look like this, though:
BER
BERA
If I import data like "BERA12342" I will get two matches (the MsgBox here is for checking what my code does and will be deleted later). As the candidate BERA comes after the candidate BER in my source list it's working fine, because the 2nd "match" just overwrites the first. If they were to be in a different order I would get a false match. Is there a way to only always get one match? Or will I have to make sure the source list is ordered in a certain way?
I suppose you have the candidate list in an Excel file.
If so, you can use a for each loop on the range of your candidate list
To get the full candidate list, even if it grows between two executions, you can use the first cell as a starting point and find the last cell with the toDown() method.
I don't remember its exact name but I've used it before, you can find it by recording a macro and using the Ctrl+Down shortcut.
With these two cells you have the range of your candidate list.
Try to use that formula to check if the cell contains the string:
=IF(IFERROR(FIND("string",A2,1),0)+IFERROR(FIND("string",A2,1),0)>0,"TRUE","FALSE")
source: https://best-excel-tutorial.com/59-tips-and-tricks/600-search-for-string-in-column
Then filter them out and write a for loop to move forward.
I have a spreadsheet with hundreds of URLs. Each URL has a search-engine friendly name in it, followed by a numeric ID, with a "/1" at the end. here's an example:
http://www.somesite.com/directory/varying-file-names-Guide/431/1
in this case, the 431 is the numeric ID. I'm trying to extract this numeric ID into its own column, but my lack of Excel knowledge is definitely holding me back. I've found a few examples, but my attempts to customize these example to match my needs results in errors. In all cases, the value I need to extract will always be between "-Guides/" and "/1" in the URL.
any help would be greatly appreciated.
thanks!
Assuming your URL in A1 try this formula in B1 to extract that number
=REPLACE(LEFT(A1,LEN(A1)-2),1,SEARCH("Guide/",A1)+5,"")
assumes "Guide" not "Guides" - if it's "Guides" then the 5 needs to be a 6.....,i.e.
=REPLACE(LEFT(A1,LEN(A1)-2),1,SEARCH("Guides/",A1)+6,"")
...or a different approach that will extract any number that ends at the 3rd charcater from the end
=LOOKUP(10^5,RIGHT(LEFT(RIGHT(A1,7),5),{1,2,3,4,5})+0)
extracts up to 5 digits
This formula should work regardless of the word preceding the numeric ID. Assuming your URL is in cell A1,
In cell B1:
=SUBSTITUTE(LEFT(A1, LEN(A1) - 2), "/","||", LEN(LEFT(A1, LEN(A1) - 2)) - LEN(SUBSTITUTE(LEFT(A1, LEN(A1) - 2), "/","")))
In cell C1:
=RIGHT(B1,LEN(B1)-FIND("||",B1)-1)
Thanks to everyone who answered. A co-worker of mine also came up with a different approach that also worked.
=MID(A6,FIND("uide/",A6,1)+5,LEN(A6)-FIND("tion/",A6,1)-6)
I thought I'd include this for anyone else facing the same issue. Interesting to see the various ways people approach the problem.