Formula to add amounts based on cell above

Mldeuser

Well-known Member
Joined
Dec 27, 2008
Messages
573
Office Version
  1. 365
Platform
  1. Windows
Hello

I am looking for a formula that will look in column E for stx if found it will look at the cell above for the word sundry if found it will add the amount in column I for the stx row.

Cell E2 = stx
Cell E1 = sundry
Then add cell I2

I then need another formula that would look in column E for the word sundry if found it would look at the cell below for the word stx if none is found it would add the amount in column I

Thank you
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Please show us a sample of your data and expected results.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Here is a sample

Thank you for your time on this
 

Attachments

  • Sample.PNG
    Sample.PNG
    115.5 KB · Views: 6
Upvote 0
Please clarify the data and the expected results. Thiis what I come up with:
Mr excel questions 66.xlsm
ABCDEFGHI
11st formula2nd formulaa
2675675b675
3sundry
4stx
5c
6stx
7g
8f
Mldeuser
Cell Formulas
RangeFormula
A2A2=IF(AND(ISNUMBER(MATCH("stx",$E$1:$E$11,0)),"sundry"=INDEX($E$1:$E$11,MATCH("stx",$E$1:$E$11,0)-1,1)),I2,"")
B2B2=IF(AND(ISNUMBER(MATCH("sundry",$E$1:$E$11,0)),"stx"=INDEX($E$1:$E$11,MATCH("sundry",$E$1:$E$11,0)+1,1)),I2,"")



Mr Excel has a tool called xl2bb (link below) that allows you to post mini worksheets. This means the forum doesn't have to guess at your scenario and get your requirement incorrect which wastes everyones time. Please help the forum help you. If you cannot use the add in, post the data in a table (label the rows and columns please). Of course sanitize your data for privacy.

Thanks in advance!


Edit: Just saw your screen shot. Are we looking in the same ROW intersection with Column E or all of Column E?


try this:

Mr excel questions 66.xlsm
ABCDEFGHI
10
111st formula2nd formulaa25
12  b29
13  sundry26
1414 stx14
15  c25
16 22sundry22
17  g29
18  f12
Mldeuser
Cell Formulas
RangeFormula
A12:A18A12=IF(AND(E12="stx",E11="sundry"),I12,"")
B12:B18B12=IF(AND(E12="sundry",E13<>"stx"),I12,"")
 
Last edited:
Upvote 0
Hello

The amount for the first formula should be 7.99 as there is only one row with stx in column e that has sunry in the cell above.
The amount of the second formula should be 3,082.82 as there is only one row with sundry in column e that there is not a row below it with stx in column e

Thank you
 
Upvote 0
Hello

The amount for the first formula should be 7.99 as there is only one row with stx in column e that has sunry in the cell above.
The amount of the second formula should be 3,082.82 as there is only one row with sundry in column e that there is not a row below it with stx in column e

Thank you
well, use the formulas I have above in your workbook and see if they work. I'm not going guess at recreating a scenario verbatim when you can paste it in a table.
 
Upvote 0
Hello

The formulas are not working, the information in the rows will change from month to month so the cells containing stx with the above cells containing sundry will not be the same each month same for formula two

Thank you
 
Upvote 0
Hello

The formulas are not working, the information in the rows will change from month to month so the cells containing stx with the above cells containing sundry will not be the same each month same for formula two

Thank you
then please post your data, xl2bb or in a table (labeling rows and columns). The formulas I gave you reference the exact columns your written text states.
Help the forum help you!
 
Upvote 0
Hello

Work will not allow me to download the addin. I hope the below helps with what I am trying to do with the two formulas. Since there are more rows with ele in column E I thought it would be best to use this in the formula.

Thank you
Sample1.PNG
 
Upvote 0
Please highlight the area, click copy. Come to this forum, and paste into a table. If you can't label row/columns just says what the top left cell address is.
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,067
Members
449,090
Latest member
fragment

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top