I need some help with an Excel formula
╔═══════════════╦═════════╗
║ SALE PRICE ║ Bonus ║
╠═══════╦═══════╬═════════╣
║ 0 ║ 14999 ║ $25.00 ║
╠═══════╬═══════╬═════════╣
║ 15000 ║ 20000 ║ $50.00 ║
╠═══════╬═══════╬═════════╣
║ 20001 ║ 25000 ║ $125.00 ║
╠═══════╩═══════╬═════════╣
║ 25001+ ║ $250.00 ║
╚═══════════════╩═════════╝
The above table is the data I need to extract when the sale price is entered into a field.
For example.....
Cell D24 is the BONUS FIELD
Cell E29 is the SALE PRICE FIELD
If the sale price is between $0-$14,999, then I want cell D24 to auto-populate $25.00. Then, if the sale price is between $15,000-$20,000 I want Cell D24 to auto-populate $50. Then, if the sale price is between $20,001-$25,000 I want Cell D24 to auto-populate $125. Then finally, if the sale price is $25,001+ I want Cell D24 to auto-populate $250.
try,
=25+(A2>15000)*25+(A2>20000)*75+(A2>25000)*125
this formula seems to work but only the first rule being 0-14999.....how do I add another rule to the existing formula.
=IF(AND(E29>=0,E29<=14999),25,0)
Related
I need some help for my Excel formula. I am trying to select specific rows based on the values in those rows.
Let's say these are my values:
╔══════════╦═════════╦══════╗
║ Data ║ Month ║ Name ║
╠══════════╬═════════╬══════╣
║ Value 1 ║ january ║ mark ║
║ Value 2 ║ january ║ mark ║
║ Value 3 ║ january ║ rick ║
║ Value 4 ║ january ║ rick ║
║ Value 5 ║ march ║ mark ║
║ Value 6 ║ march ║ mark ║
║ Value 7 ║ march ║ rick ║
║ Value 8 ║ march ║ rick ║
║ Value 9 ║ august ║ mark ║
║ Value 10 ║ august ║ rick ║
╚══════════╩═════════╩══════╝
The value in A1 = january
The value in A2 = mark
I want to list all the rows where the month is A1 and the name is A2.
This should be my result:
║ Value 1 ║ january ║ mark ║
║ Value 2 ║ january ║ mark ║
I have tried using INDEX combined with IF, but with no succes. I am looking for either a VBA solution or a formula, whatever is best.
I am assuming that:
'Data' is in Sheet1!A1, 'Month' is in Sheet1!B1 and 'Name' is in Sheet1!C1.
On Sheet2!A1 is the value of 'Month' which you want to filter out and on Sheet2!A1 is the value of 'Name' you want to filter out.
Make a new column in Sheet1!D1 (beside 'Name') and give it a header, eg. 'Tag'. In the first row, D1 (under 'Tag') write the formula
=IF(AND(B2=Sheet2!$A$1,C2=Sheet2!$A$2),MAX($D$1:D1)+1,"")
Pull (copy) the above formula down till the last row of your table.
On Sheet2, replicate your table headers, this time in B1, C1 and D1 (as A1 & A2 already have your filter values).
// now everything is for Sheet2
In B2 write the following formula:
=IFERROR(INDEX(Sheet1!A:A,MATCH(ROWS($B$2:B2),Sheet1!$D:$D,0)),"")
Paste this formula in the new filter table rows.
Change values in Sheet2!A1 (Month) and Sheet2!A2 (Name) to test if the correct rows are being filtered.
I have a huge excel sheet that looks like this:
╔══════╦══════╦═════╗
║ A ║ B ║ C ║
╠══════╬══════╬═════╣
║ Jack ║ 2001 ║ 1,5 ║
║ Jack ║ 2002 ║ 2,0 ║
║ Jack ║ 2003 ║ 1,0 ║
║ Jack ║ 3001 ║ 3,5 ║
║ Jack ║ 3002 ║ 4,0 ║
║ Jack ║ 3003 ║ 1,0 ║
║ Jill ║ 2001 ║ 3,0 ║
║ Jill ║ 2002 ║ 5,0 ║
║ Jill ║ 2003 ║ 2,0 ║
║ Jill ║ 3001 ║ 0,5 ║
║ Jill ║ 3002 ║ 6,0 ║
║ Jill ║ 3003 ║ 2,5 ║
╚══════╩══════╩═════╝
Column B contains many different numbers, but they all begin with digits 2, 3 or 8. The numbers in column B are always be 4 digits long; I'm only interested in checking the first digit.
I need to add together the values of column C, where the first digit of the corresponding cell in column B is either 2*, 3* or 8*. What I need is to create a formula that does this (Ruby-esque pseudocode):
sum = 0
spreadsheet_rows.each do |row|
if row.a == "Jack" and row.b == "2*" # Note the second wildcard condition.
sum += row.c
end
end
puts sum # Should print 4,5 in this example.
I'm trying to use the following formula in Excel to accomplish this:
=SUMIFS($C:$C; $A:$A; "Jack"; $B:$B; "=2*")
I know that Excel does not support wildcard conditions for numbers, however, I have formatted column B as type "Text" in Excel, so I thought it would be treated as such, but it appears that it is still treated as an int.
Is there a different way of applying a wildcard condition in =SUMIFS for number values in Excel? Perhaps there's a way to somehow "cast" the integers to strings in the formula? I haven't found a way to do it (yet).
I'm using Excel for Mac 2011.
I'd go for the less readable, but more powerful SUMPRODUCT:
=SUMPRODUCT(($A:$A="Jack") * (LEFT($B:$B;1)="2") * ($C:$C))
which will generate boolean arrays for each of the conditions (first and second brace part) which it will multiply with the third one (your numbers).
EDIT:
As noted in comments, #VALUE errors can appear if any value in column C cannot be converted to a number. To avoid that, you could use the syntax suggested by barry houdini
=SUMPRODUCT(($A:$A="Jack") * (LEFT($B:$B;1)="2"); $C:$C)
and let SUMPRODUCT skip over non-numbers.
This works for me:
=SUM((A1:A12=F2)*(LEFT(B1:B12)=""&F3)*C1:C12)
entered as an array formula with CtrlShiftEnter
You ask how to cast numbers to strings; concatenating an empty string and a number ""&F3 is one way to do that.
{=SUM((A1:A12=F2)*(LEFT(B1:B12)=""&F3)*C1:C12)}
No need for an arrays as shown above just type following formula which gives equal results to above Arrays formula
=SUMPRODUCT((A1:A12=F2)*(LEFT(B1:B12)=F3&"")*C1:C12)
Remember difference [Arrays=""&F3] vs [SUMPRODUCT= F3&""]
I shall be bring to your kind I am just very very very happy to see your work and the way you authoritatively asked question as as
"I know that Excel does not support wildcard conditions for numbers, however, I have
formatted column B as type "Text" in Excel, so I thought it would be treated as
such, but it appears that it is still treated as an int."
SUMPRODUCT only not work when we have to get output in TEXT
Hoping your verification about all above and kindly highlight at prominent place
I have a excel sheet like below. Consider the sno column as Excel numbering.
So all the columns except DateTime are merged. I want to Merge the DateTime cells and want to delete the empty records. I tried a few formulas with no success. Is this possible
I tried below formula but its giving weird results becoz of datetime values i think.
=INDEX($A$1:$A$<ENDROW>,(B1-1)*2+1,1)&" "&INDEX($A$1:$A$<ENDROW>,(B1-1)*2+2,1)
I have this:
╔═════╦════════╦══════════╦═════════╦═════════════╗
║ sno ║ Action ║ DateTime ║ User ID ║ Name ║
╠═════╬════════╬══════════╬═════════╬═════════════╣
║ 1 ║ INSERT ║ 8-Nov-13 ║ childsk ║ Keri Childs ║
║ 2 ║ ║ 16:06:43 ║ ║ ║
║ 3 ║ INSERT ║ 8-Nov-13 ║ childsk ║ Keri Childs ║
║ 4 ║ ║ 16:04:27 ║ ║ ║
╚═════╩════════╩══════════╩═════════╩═════════════╝
Expected Output:
╔═════╦════════╦═══════════════════╦═════════╦═════════════╗
║ sno ║ Action ║ DateTime ║ User ID ║ Name ║
╠═════╬════════╬═══════════════════╬═════════╬═════════════╣
║ 1 ║ INSERT ║ 8-Nov-13 16:06:43 ║ childsk ║ Keri Childs ║
║ 2 ║ INSERT ║ 8-Nov-13 16:04:27 ║ childsk ║ Keri Childs ║
╚═════╩════════╩═══════════════════╩═════════╩═════════════╝
You have two tasks to perform.
To merge date and time into a single cell. This is simply done by (Cell C1 contains the formula (as text) that is used in B1.)
and formatting B1 as Custom -> d-mmm-yy hh:mm:ss.
Then you can copy the results (as values) and format to a destination column.
Remove extra rows. You can use the code below (make sure you change the number of repetitions from 10 to whatever you need).
.
Sub del_skip_rows_repeat_caller()
Call del_skip_rows_repeat(1, 10)
End Sub
Sub del_skip_rows_repeat(nrows As Integer, nrep As Integer)
Dim i As Integer
For i = 1 To nrep
Call del_skip_rows(nrows)
Next i
End Sub
Sub del_skip_rows(nrows As Integer)
Dim rng As Range
Set rng = Range(Selection, Selection.Offset(nrows - 1, 0)).EntireRow
'rng.Select
rng.Delete Shift:=xlUp
Set rng = Selection.Offset(1, 0).Cells(1, 1)
rng.Select
End Sub
I am trying to create a cell in my worksheet that summarizes all the data in the row. I have found a way to combine all the fields into the first column, but I also need it to include the header name and it needs to ignore fields that are blank. (https://stackoverflow.com/a/13074838)
My excel file has over 50 columns and 5000 rows so I think this might be a job for a macro. Any ideas on how to accomplish this?
╔═════════╦══════╦═════╦═══════════╦═══════╗
║ Summary ║ Name ║ Age ║ County ║ ZIP ║
╠═════════╬══════╬═════╬═══════════╬═══════╣
║ ║ Sue ║ ║ Snohomish ║ 98144 ║
║ ║ Bob ║ 36 ║ Pierce ║ 98335 ║
║ ║ Pat ║ 32 ║ Spokane ║ ║
║ ║ Jim ║ 40 ║ King ║ 98101 ║
╚═════════╩══════╩═════╩═══════════╩═══════╝
Cell A2 would have the following contents:
Name: Sue
County: Snohomish
ZIP: 98144
Cell A3:
Name: Bob
Age: 36
County: Pierce
ZIP 98335
Cell A4:
Name: Pat
Age: 32
County: Spokane
What you need is a formula that :
Uses the IF function to test whether each information cell has data (I'm assuming that you will always have the name).
If the cell does, concatenate the character representation of the ASCII code for a carriage return (CHAR(10)) and the data for that cell.
Be sure to turn on wrapping for the formula cell, or the text that is displayed won't show the line breaks.
The resulting formula looks like this.
="Name: " &B1&
IF(C1="","",CHAR(10)&"Age: "&C1)&
IF(D1="","",CHAR(10)&"County: "&D1)&
IF(E1="","",CHAR(10)&"Zip: "&E1)
You could get fancy and indent the data (age, etc.) by the same amount using the LEN function.
Lets say I would like to sum up values from January to March. Below is an example
╔═══════════╦════════════╗
║ Column A ║ Column B ║
╠═══════════╬════════════╣
║ 1/30/2011 ║ 1 ║
║ 1/25/2011 ║ 1 ║
║ 3/30/2011 ║ 1 ║
║ 3/25/2011 ║ 1 ║
║ 5/13/2011 ║ 1 ║
╚═══════════╩════════════╝
I did some research and found I can use the SUMIFS function
=SUMIFS(B1:B5,A1:A5,">="&DATE(YEAR(2011),MONTH(1),DAY(1)),A1:A5,"<="&DATE(YEAR(2011),MONTH(4),DAY(1)))
But for some reason instead of returning 4 it returns 0. I would really appreciate if someone could figure out why.
Thank you
I don't think Year/Month/Day do what you're expecting, see:
http://www.techonthenet.com/excel/formulas/year.php
They return the year value, month value, and day value of their argument. Try entering
=YEAR(2011)
and compare it to
=YEAR("1/30/2011")
That said, you can get what you want by just putting the dates in the quotes
=SUMIFS(B1:B5,A1:A5,">=2011-01-01",A1:A5,"<=2011-04-01")
produces 4 in my Excel.