If Statement false check next row for true condition

Fishstats

New Member
Joined
Nov 18, 2011
Messages
16
I am trying to use an if statement to enter the value of a cell into another cell if it meets a criteria. If that cell doesn't meet the criteria I want it to check the cell below it and if that cell is true I would like it to be placed in another cell.

For example if

if a1 is false but a2 is true I want it to enter the value of a2 in b1. I would like this to continue down both columns. So that any value that meets the criteria in column a be placed in column b with no blank cells or 0's in column b.

location Location is in
out in
out in
out in
in in
in
out
in
out
out
in
 
Hey circledchicken thanks. ALmos there hhaa! Thanks.

Hey but is there a way that lets say:


  • C2 compares with A2, finds a match, puts the data on E2 and F2. Then...
  • C3 compares with A3, finds a match, puts the data on E3 and F3. Then...
  • C4 compares with A4, no match, so, no data on E and F. Then...
  • C4 again compares with A5, finds a match, puts the data on E4 and F4.
  • Then Column C continues doing the same process until the en of this column..

This is pretty much what I need. Almost there. It's because right now it stops when C column finds a no match on A column.

Thanks for your help.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Opps I think Iposted the reply somewhere else.

Well

Almos there hhaa! Thanks.

Hey but is there a way that lets say:


  • C2 compares with A2, finds a match, puts the data on E2 and F2. Then...
  • C3 compares with A3, finds a match, puts the data on E3 and F3. Then...
  • C4 compares with A4, no match, so, no data on E and F. Then...
  • C4 again compares with A5, finds a match, puts the data on E4 and F4.
  • Then Column C continues doing the same process until the en of this column..


You were close ... perhaps try the following and drag down (using CTRL-SHIFT-ENTER rather than just ENTER as they are array formulae):

E2:
Code:
=IFERROR(
    INDEX(A$2:A$10,
      SMALL(
        IF(A$2:A$10 = C$2:C$10,
           ROW(A$2:A$10) - ROW(A$2) + 1),
        ROWS(A$2:A2))),
    "")

F2:
Code:
=IFERROR(
    INDEX(B$2:B$10,
      SMALL(
        IF(A$2:A$10 = C$2:C$10,
           ROW(A$2:A$10) - ROW(A$2) + 1),
        ROWS(A$2:A2))),
    "")

If all the codes in a given column will be unique then you can reduce the F2 formula down to a SUMIF.
 
Upvote 0
Sorry, your question is still not completely clear to me. Perhaps like this:

E2 and drag down (CTRL-SHIFT-ENTER rather than just ENTER):
Code:
=IFERROR(
    INDEX(C$2:C$10,
      SMALL(
        IF(COUNTIF(A$2:A$10, C$2:C$10),
           ROW(C$2:C$10) - ROW(C$2) + 1),
      ROWS(C$2:C2))),
    "")

F2 and drag down (just ENTER):
Code:
=IF(E2="",
    "",
    SUMIF(A$2:A$10, E2, B$2:B$10))

This says, list the 'Supplier' codes that have a matching 'All skus' code, and find the associated sum of the 'All skus qty'.
 
Last edited:
Upvote 0
Sorry, your question is still not completely clear to me. Perhaps like this:

E2 and drag down (CTRL-SHIFT-ENTER rather than just ENTER):
Code:
=IFERROR(
    INDEX(C$2:C$10,
      SMALL(
        IF(COUNTIF(A$2:A$10, C$2:C$10),
           ROW(C$2:C$10) - ROW(C$2) + 1),
      ROWS(C$2:C2))),
    "")

F2 and drag down (just ENTER):
Code:
=IF(E2="",
    "",
    SUMIF(A$2:A$10, E2, B$2:B$10))

This says, list the 'Supplier' codes that have a matching 'All skus' code, and find the associated sum of the 'All skus qty'.

Hello circledchicken.

That was exactly what I needed, sorry if I was making it too confusing. It worked perfect. I have many lists, some share the same skus, others not. With this formula I can check which list has which skus, and add its corresponding quantity.

One more thing,so I understand better:Would you be able to quickly give me an explanation of how the codes works.

Thank you very much for all your help circledchicken :)

I bet someone will find this helpful too.
 
Upvote 0
Hi gpaco2,

You're welcome - thanks for the feedback.

I still think you might be making it too complicated for what you need. For example:
  • remove columns E and F
  • in D1 enter 'Supplier qty'
  • in D2 and drag down: =SUMIF(A$2:A$10, C2, B$2:B$10)
You can then just use autofilter on column D to select all the non-zero quantities.

For more on autofilter see: Excel Filters: Excel 2007 AutoFilter Basics
For more on the SUMIF function see: SUMIF Formulas | RAD Excel
 
Upvote 0
Hi gpaco2,

You're welcome - thanks for the feedback.

I still think you might be making it too complicated for what you need. For example:
  • remove columns E and F
  • in D1 enter 'Supplier qty'
  • in D2 and drag down: =SUMIF(A$2:A$10, C2, B$2:B$10)
You can then just use autofilter on column D to select all the non-zero quantities.

For more on autofilter see: Excel Filters: Excel 2007 AutoFilter Basics
For more on the SUMIF function see: SUMIF Formulas | RAD Excel


Hello circledchicken, thanks for all the information.

I'll take a look at the other way you mentioned. I might be doing it to complicated the other way :) haa!

Well anyway, thanks and see you on another excel adventure. See you buddy. :)
 
Upvote 0
Hello circledchicken, thanks for all the information.

I'll take a look at the other way you mentioned. I might be doing it to complicated the other way :) haa!

Well anyway, thanks and see you on another excel adventure. See you buddy. :)
You're welcome, see you :).
 
Upvote 0
hello people

i have a question hear,

please refer the below table first


AMOUNTPMT
300
300
800
800
1200
1500
1700
2000
2000
2000
2200

<colgroup><col><col></colgroup><tbody>
</tbody>

in this table i have to fill in a fixed amount i.e 800 Rs constant, where in if the PMT coloum gives negative, it should automatically skip that row and apply 800 Rs in the next row, again if PMT goes negative, check the next row and apply again 800 ... so on and so fourth ..... and if possible please try first without using macro ....

thanks ....
 
Upvote 0
Hi,

Maybe something like this, dragging down the formula in each column. Note that you need to use CTRL-SHIFT-ENTER not just ENTER for columns E and G.

Sheet1
ABCDEFG
1SiteLocationDatesitelocationdate
2ain12/01/2011ain12/01/2011
3bin12/02/2011bin12/03/2011
4cout12/03/2011fin12/08/2011
5dout12/04/2011hin00/01/1900
6eout12/05/2011
7fin12/06/2011
8gout12/07/2011
9hin12/08/2011
10iout12/09/2011

<thead>
</thead><tbody>
</tbody>
Excel 2010

Worksheet Formulas
CellFormula
F2=IF(E2<>"","in","")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
E2=IFERROR(INDEX(A$2:A$10,SMALL(IF(B$2:B$10="in",ROW(A$2:A$10)-ROW(A$2)+1),ROW(A1))),"")
G2=IFERROR(INDEX(C2:C10,MATCH(E2&F2,A$2:A$10&B$2:B$10,0)),"")

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}. Note: Do not try and enter these manually yourself

<tbody>
</tbody>

Hi..
I have tried the same example for Column E with shared formula for cell E2 but i can get only the result for cell E2 and while dragging down all cell E3, E4.... are coming as blank
Pls suggest the formula for cell E3 & E4...
 
Upvote 0

Forum statistics

Threads
1,215,128
Messages
6,123,204
Members
449,090
Latest member
bes000

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