looping code problem

excel_lover

New Member
Joined
Aug 31, 2008
Messages
22
HI

I have a looping code problem I was wondering if you could have a quick look for me.

I have two tables of information. The first is a matrix with some distances. The second is a table of distribution. Ive been trying this for a long time now with limited success using a truth table but i've realised the only way to do this is in code. Ive got limited experience with this so please point me in the right direction.

Ive written some steps explaining what each table does here -

Step 1 Check for lowest value B4:F4 in Table 1 (in example is 10)
Step 2 Check corresponding column destination available capacity in table 2 (Example 500)
Step 3 Distribute as much as possible from source in table 2 (500)
Step 4 Reduce value in capacity line by value taken from source
Step 5 If some source remains move back to table 1 and find next nearest column Dest
Step 6 Repeat step 2 until all source is gone in row
Step 7 Check for lowest value B5:F5 in Table 1
if run out of capacity at all sites stop code
etc
until Table 1 column B is empty

Ive posted a spreadsheet here http://www.turboupload.com/files/get/IQL2DAlAZZ/code-to-loop-through-one-table-and-alter-another.zip

the example has some before and after tables in it aswell to help explain what im trying to do. Its very small and formatted o its easy to see whats happening.

Thanks for taking a look.<!-- / message --><!-- attachments -->
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You picked a horrible site to upload to. I can't sit there for five minutes listening, 10 times over how, I'm going to get free stuff I don't need.
 
Upvote 0

Forum statistics

Threads
1,215,831
Messages
6,127,142
Members
449,363
Latest member
Yap999

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