Computing.Net > Forums > Office Software > Excel Loop Formula - Need Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel Loop Formula - Need Help

Reply to Message Icon

Name: SnoopyAceVF31
Date: January 17, 2008 at 09:51:03 Pacific
OS: Window XP
CPU/Ram: Pentium 4
Product: Dell
Comment:

I'm using MS Office Prof. Edition 2003 Excel. I have a spreadsheet "BOM" with 3 columns, Parts Number, Description, and Quantity. I would like to generate a formula to automatically show a list of parts that has nonzero quantity. In orther words, either delete the parts with zero in quantity or in another sheet to show parts with quantity as none zero. I tried to in another sheet, in the same workbook, generate formula using nested if functions to copy contents from "BOM" sheet if the quantity is not zero, and skip if the quantity is zero. However, if function only gives one iteration, not like loop can continue check quantity till it reaches to the next nonzero quantity. How can I write code/formula to keep skipping zero quantity till next nonzero quantity and copy the corresponding contents from "BOM" sheet? Thanks.

Best Regards,
Steven Lu



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: January 17, 2008 at 16:46:14 Pacific
Reply:

An Excel formula can not loop. You need to use an array formula over a range of cells.

Let's assume your Part Numbers are in A1:A19, your Descriptions are in B1:B19 and your Quantities are in C1:C19.

To place a list of the Part Numbers with non-zero quantities in Column D, select D1:D19 and type in this formula:

=IF(ISERROR(INDEX(A1:A19,SMALL(IF(C1:C19>0,ROW(INDIRECT("1:"&ROWS(C1:C19)))),ROW(INDIRECT("1:"&ROWS(C1:C19)))))),"",INDEX(A1:A19,SMALL(IF(C1:C19>0,ROW(INDIRECT("1:"&ROWS(C1:C19)))),ROW(INDIRECT("1:"&ROWS(C1:C19))))))

When you are done typing in the formula, use Ctrl-Shift-Enter to enter it as an array formula. If you do this correctly, brackets {} will appear around the formula. No, you cannot just type the brackets into the formula bar and expect it to work.

To get the Quantities in Column F, select F1:F19 and type in this array formula, again using Ctrl-Shift-Enter when you are done.

=IF(ISERROR(INDEX(C1:C19,SMALL(IF(C1:C19>0,ROW(INDIRECT("1:"&ROWS(C1:C19)))),ROW(INDIRECT("1:"&ROWS(C1:C19)))))),"",INDEX(C1:C19,SMALL(IF(C1:C19>0,ROW(INDIRECT("1:"&ROWS(C1:C19)))),ROW(INDIRECT("1:"&ROWS(C1:C19))))))

Hopefully you can see the difference between the 2 formulae and figure out how to get the Descriptions from B1:B19 into E1:E19.

Good Luck!


0

Response Number 2
Name: Jennifer SUMN
Date: January 17, 2008 at 17:24:56 Pacific
Reply:

Gosh, that's a wide post. I had trouble finding the "submit followup button!" :)

Life's more painless for the brainless.


0

Response Number 3
Name: DerbyDad03
Date: January 18, 2008 at 05:54:58 Pacific
Reply:

I'm not sure what you mean by "wide".

I don't know how you view this website, but all posts that I see are about 5.5 inches wide in the middle of my screen, with the list of forums (1.5") on the left and ads (2") on the right.

There's at least 2.5 inches of blank grey background on both sides.

My post is about 11" tall, but only 5.5 wide, with the Submit button below my post.

15" wide flat screen monitor, set to 1280 x 1024


0

Response Number 4
Name: seawatch
Date: January 20, 2008 at 09:52:09 Pacific
Reply:

It's wide on mine also.

Coming home from very lonely places, all of us go a little mad: whether from great personal success, or just an all-night drive, we are the sole survivors of a world no one else has ever seen.
-


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel Loop Formula - Need Help

Excel Formula, need help! www.computing.net/answers/office/excel-formula-need-help/6717.html

Excel 2007 Formula Question www.computing.net/answers/office/excel-2007-formula-question/9280.html

Multi-colored dots from fields in Excel www.computing.net/answers/office/multicolored-dots-from-fields-in-excel/9206.html