trying to get an excel spreadsheet to do what I need and im basically computer illiterate. Any help would be appreciated
Basically what I need is the below statements combined
If E8 = Officer and G8 = Active Duty then 1
If E8 = Officer and G8 = Active Reserve then 2
if E8 = Enlisted and G8 = Active Duty then 3
If E8 = Enlisted and G8 = Active Reserve then 4
Ive been able to figure out some basic and, if statements but this one with multiple outcomes is throwing me for a loop, Also it all needs to go into one cell if possible. Thanks guys
=MATCH(E8&G8,{"OfficerActive Duty","OfficerActive Reserve","EnlistedActive Duty","EnlistedActive Reserve"},0)
OR
=(MATCH(E8,{"Officer","Enlisted"},0)-1)*2+MATCH(G8,{"Active Duty","Active Reserve"},0)
This is what you need:
IF(AND(E8="Officer",G8="Active Duty"), 1,
IF(AND(E8="Officer",G8="Active Reserve"), 2,
IF(AND(E8="Enlisted",G8="Active Duty"), 3, 4)))
If you need to use this quite a lot in the future, better to set up as a table to look up and here is how you can do it with an array formula (click Ctrl + Shift + Enter together):
=INDEX($C$2:$C$5,MATCH(E2&F2,$A$2:$A$5&$B$2:$B$5,0),1)
This way, you can dynamically update your criteria any time you want.
Plus, you can set up a drop down list from your criteria like this (Data > Data Tools > Data Validation):
Related
As you can see in my picture.
There is a table to the right.
Cell D3 has the option to select 90.0, 95.0, 99.0, and 99.9
Cell D4 is a % value
Cell D5 I have: IF(AND(D3=90,3/D4<9),3,4) Obviously if the user selects 90 for D3, then I want to determine which 2 X choices either 3 or 4 from the table are used based on the value of Y which I get by the 3/D4. This statement is working 100% correct.
MY QUESTION, How do I add the other parts of the table to this same line of code for when D3 = 95, 99, and 99.9?
I try this: =IF(OR(AND(D3=90, 3/D4<9),3,4, IF(AND(D3=95,4/D4<16),4,5)))
Try
=CHOOSE(MATCH(D3,{90,95,99,99.9},0),
IF(3/D4>= 9, 4,IF(3/D4>= 5,3,NA())),
IF(3/D4>=16, 5,IF(3/D4>= 7,4,NA())),
IF(3/D4>=20, 7,IF(3/D4>= 7,6,IF(3/D4>=6,5,NA()))),
IF(3/D4>=32,10,IF(3/D4>=15,9,IF(3/D4>=9,8,IF(3/D4>=8,7,NA()))))
)
In this formula MATCH(D3,{90,95,99,99.9},0) will return 1, 2, 3, or 4. This is used by CHOOSE to select the login in one of the four lines below.
Each of the next four lines is a nested IF statements. The question as asked has integer thresholds for 3/D4 and is a little ambiguous about things that fall in the gaps: for example, how do you handle C=90 and 3/D4=8.5. I've made the decision/assumption that when 3/D4<9, return 3. If that's wrong (for instance you want to round 3/D4 to an integer) you can modify the formula accordingly.
I've also made the decision to return NA when 3/D4 is below the lowest threshold. You can modify the formula to change that behavior too.
Sat down for a small project that's supposed to count combat details for my tabletop gaming sessions during lunch, turns out the excel code hates me.
C8 = CREATURE MAX HP
D8 = CREATURE CURRENT HP
E8 = CREATURE DAMAGE HEALED
F8:L8 = PC1:PC8 DAMAGE CAUSED
My formula for adding these together is contained in cell D8 and looks like this:
=C8-SUM(F8:L8)+E8
But I don't want my cell to add higher than what's contained in C8. How can I keep that from happening?
Does min work for you? =MIN(C8-SUM(F8:L8)+E8, C8) – Alexis Olson 8 mins ago
I'll go ahead an make this into an answer.
You can approach this in a couple of ways. The first is using MIN which takes the lesser of the two arguments.
=MIN(C8-SUM(F8:L8)+E8, C8)
You could also use an IF(test, result if true, result if false) function.
=IF(C8-SUM(F8:L8)+E8 > C8, C8, C8-SUM(F8:L8)+E8)
or equivalently, pulling the C8 value out, you have
=C8 + IF(E8 > SUM(F8:L8), 0, E8 - SUM(F8:L8))
I have an issue at the moment which I'm not able to resolve even with multiple combinations of If and Vlookups. I'm not doing this right.
I have a sheet which has the names of the products and an empty column for the Sl Number. The Sl number needs to be retrieved from Sheet 2 if it matches the value in the adjacent cell of the formula (This I know can be possible with Vlookup). However, I am trying to display the value even if the match is not exact. By that I mean if the product name has all the values as on the sheet 1 but also has additional information in brackets, then the value should still be displayed.
Sheet 1
Formula in A2 - A7 = "=VLOOKUP(B2, Sheet2!B:E, 2, 0)"
Sheet 2
The complete data
Is this possible?
Thanks in advance.
Apologies, I'm new here and not sure how this works. So trying to do the right thing but may take some time.
Thanks Frank and Tim. I have another extended question to this.
Is there a way to retrieve the value by ignoring text in brackets on the lookup cell itself?
For example:
Sheet 1
Sl Number Name
123454 Cream SPF 30+ 50g
**NA** Bar Chocolate 70g X 6 (Sample)
234256 Hand Wash 150ml
26786 Toothpaste - Whitening 110g
Sheet 2
ID Name Sl number Manufacturer Quantity
8 Collagen Essence 10ml 456788 AL 87
9 Hand Wash 150ml 234256 AD 23
10 Bar Chocolate 70g X 6 835424 AU 234
Row 2 on Sheet 1 has the name that includes (Sample) and the same product on sheet 2 does not contain the (Sample) for that product. Is there a way I can use lookup in the above scenario?
Thank you
Tim's comment
=VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) as long as the "Extra" info is tagged onto the end of the name, and none of your product names is a
substring of another product name. – Tim Williams 53 mins ago
Will get what you are looking for, as for getting rid of text between "(...)" use
=IFERROR(IF(FIND("(",A2),LEFT(A2,FIND("(",A2)-1),A2),A2)
To create a new column that will cut out anything that has parentheses "(...)" this presumes that all of your entries has the "(...)" at the end, i.e. far right side.
As you are new, I presume you might be interested in an explanation. I'll explain what Tim and I did. If I am incorrect, anyone is free to edit.
Based on your question, it would appear that you are familiar with Excel but not the site. This said, my understanding of the key difference between your attempt and Tim's was =VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) or specifically & "*". This introduces a Wildcard to the search parameter. So if you typed "Bob" but the actual reference was "Bob's Burger" That "*" would allow ['s Burger] to be included as part of the possible search given that you set vLookup to search for Approximate rather than exact matches. =VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) specifically , 0).
As for my part, IFERROR is effectively an catch-all for errors in IF functions. If there is a error, then X. In this case, if it does not find "(" in the cell, then it will throw an error. Since it is an error, display the original cell.
As for IF(FIND("(",A2),LEFT(A2,FIND("(",A2)-1),A2) It asks Excel to look for "(" in the cell A2, if it finds it, then it it counts from the LEFT until it finds the "(" and deletes the text one space to the left of the first "(". Thus removing the "(...)".
I have the following data in a worksheet:
column A
431620121601 5201585 - 0006 Fresh Turkey Gravy 500g 27 -Cartons 27 162
431619121602 5204059 - 0006 Fresh Bread Sauce 300g 52 -Palettes 52 312
I want to get the number of cartons or palettes from the text and put this in column B
Column B
27 Cartons
52 Palettes
Here's what i have tried so far:
=MID(A8,SEARCH(" ",A8)+12,SEARCH("-Cartons",A8)-SEARCH(" ",A8)-4)
but this gives me this:
06 Fresh Turkey Gravy 500g 27 -Cartons
Please can someone show me a better way of doing this?
I was able to achieve what you want but with helper columns.
Col I has all possible Types listed like Cartons, Palettes etc.
Then I use these formula to get the results
To find Index of what Type is matching. this formula is to be entered as an array formula i.e. type the formula and press Ctrl Shift Enter
B2 =SUMPRODUCT(--IFERROR(IF(FIND($I$2:$I$4,A2)>0,TRUE,FALSE),FALSE)*ROW($I$2:$I$4))
Get what Type is matching
C2 =INDEX($I$1:$I$7,B2)
Get the ending string
D2 =RIGHT(A2,LEN(A2)-FIND(C2,A2)+1)
Get the last number
E2 =SUBSTITUTE(RIGHT(SUBSTITUTE(D2," ",REPT(" ",50)),50)," ","")
replace the last number and the Type with blank and add the Type at the end
F2 =TRIM(SUBSTITUTE(SUBSTITUTE(D2,E2,""),C2,"")) & " " & C2
Drag all the formulas down for each row of your data. Take note of the column I.
I know a UDF probably seems like overkill, but I am a huge fan of regular expressions, and I wish they were more mainstream within the VBA community the way they are in many other technologies.
So, with that in mind, here is a Regex solution to your problem:
Function UNITS(InputText As String) As String
Dim rx As New RegExp
Dim match As MatchCollection
rx.Pattern = "(\d+ )-([A-Za-z]+)"
If rx.Test(InputText) Then
Set match = rx.Execute(InputText)
UNITS = match(0).SubMatches(0) & match(0).SubMatches(1)
End If
End Function
The best thing about the Regex is the scalability. This can adapt in ways an inline formula would have trouble doing with irregular data.
Also, in the example above, the rx might be better suited as a global.
To use Regular Expressions, you will have to add a reference to "Microsoft VBScript Regular Expressions 5.5" to your project.
I want you to have some fun. I need something specific.
First i must explain what i do. I use a simple codification for product prices at retail store, because i dont want people know the real price for themselves. So i change the original numbers to another subtracting the number 9 for each number.
Normally I manually write down all the prices with this codification for every product.
So.. for example number 10 would be 89. (9-1 = 8) and (9-0 = 9)
Other examples:
$128 = 871
$75 = 24
$236 = 763
$9 = 0
Finally i put 2 number nines (9) at the beginning of the codified price also, to confuse people who might think that number could be the price.
So the examples i used before are like this:
99871 (means $128)
9924 (means $75)
99763 (means $236)
990 (means $9)
Remember that i need 2 (two) nines before the real price. The real prices never start with 0 so, the nines at the beginning exist only to confuse people.
Ok. So, now that you understand, here comes the 2nd part.
I have an excel whith hundreds of my products added, with prices, description, etc. And i decided it is time to use a printer and start to print this information from excel. I have a software to do that, but first i need to have the codified prices in the excel also.
The fun part begins when i want to convert the real prices that are already written in my excel document into a new column AUTOMATICALLY. So that way i don´t have to type again all the prices in codified form for the old and new items i add in the future.
Can someone help me with this? Is it even possible?
I tried with =A1-9999 but, it works well with 2 character number only. Because if the real price is 5, i will get 3 nines: 9994(code). And if the price is 234 i will get only 1 nine 9765(code). And it is a condition i need to have the TWO nines at first.
Thank you very much in advanced!
Though you have requested for formula , I am suggesting VBA program which seems to me very convenient.
You have to open VBE and insert a module and copy the program. Change the code lines wherever indicated to suit your requirements for sheets etc.
Sub NumberCode()
Dim c As Range
Dim LR As Integer
Dim numProbs As Long
Dim sht As Worksheet
Dim s As Integer
Dim v As Long
Dim v1 As Long
Set sht = Worksheets("Sheet1") ' change as per yr requirement
numProbs = 0
LR = sht.Cells(Rows.Count, "A").End(xlUp).Row
For Each c In sht.Range("A1:A" & LR).Cells
s = Len(c)
v = c.Value
v1 = 99
For s = 1 To Len(c)
v1 = v1 & (9 - Mid(c, s, 1))
Next
c.Offset(0, 1).Value = v1
v1 = 99
numProbs = numProbs + 1
Next
MsgBox "Number coding finished"
End Sub
Sample sheet of results is appended below.
I will be using helper cells but you could dump it all into one cell if you want since you are only dealing with 4 characters.
For the purpose of this example, I am assuming your original price list starts in B11.
=IFERROR(9-MID($B11,COLUMN(A1),1),"")
Place that in D11 and copy to the right three more times so you have it from D11 to G11. That formula strips off 1 character from your price and subtracts that character from 9. When you go the next column it repeats itself. If you do not have that many characters, it will return "".
In C11 you will build your number based on the adjacent 4 columns using this formula:
="99"&D11&E11&F11&G11
It places 99 in front then adds the numbers from the adjacent 4 columns.
Select cells C11 to G11 and copy and paste downward beside your data column as far as you need to go.
An alternate more concise method would be:
=REPT(9,LEN(B11)+2)-B11
Perhaps I'm missing something, though simply:
=REPT(9,2+LEN(A1))-A1
seems good to me.
Regards