is this even possible?

B

Bowmanator

i'm working on a shipping log that i do now by hand and would like to
automate if possible. every load equals 1,000 and alot of the loads are split
loads.

a b c d e
1 date amount previous current total
2 3/10 2053 1000
3 1000
4 53
5 3/11 1019 53 947 1000
6 72
7 3/12 3000 72 928 1000
8 1000
9 1000
10 72

in this example it shows what i need to equal 1,000 and if there's over
1,000 left of that run i'd like the next line to show 1,000 and so on until i
can't make a full load of 1,000.

hope this sounds right
thanks
 
O

Otto Moehrbach

What is the sequence of events? You say you want to automate this. What
comes first? Detail what you enter and then what you want Excel to do (the
automate part). Then what happens next? The next date row maybe?
In short, Excel is dumb and it needs to know what is the trigger to make it
automate something. Maybe any entry in Column B? It might help if you
provide the series of steps you must do when you do this manually. Remember
that you are talking to people who know nothing about what you have or want
to have. HTH Otto
 
B

Bowmanator

Otto Moehrbach said:
What is the sequence of events? You say you want to automate this. What
comes first? Detail what you enter and then what you want Excel to do (the
automate part). Then what happens next? The next date row maybe?
In short, Excel is dumb and it needs to know what is the trigger to make it
automate something. Maybe any entry in Column B? It might help if you
provide the series of steps you must do when you do this manually. Remember
that you are talking to people who know nothing about what you have or want
to have. HTH Otto



.
what i'm doing here is trying to keep track of how many full truck loads i can ship before i run out of product that was ran on a certain day. then the next load will be a split load.

ex: on 3/10 we ran 2053 cases, that allows me to ship 2 full loads of that
days run leaving 53 cases left,
on 3/11 we run 1019 so in order to ship a full load of 1,000 i'll need the
53 cases left over from 3/10 plus 947 caes from 3/11 to equal 1000. then it
shows a balance of 72 let over from 3/11

hope this sounds better

thanks
 
B

Bowmanator

what i'm doing here is trying to keep track of how many full truck loads i
can ship before i run out of product that was ran on a certain day. then the
next load will be a split load.

ex: on 3/10 we ran 2053 cases, that allows me to ship 2 full loads of that
days run leaving 53 cases left,
on 3/11 we run 1019 so in order to ship a full load of 1,000 i'll need the
53 cases left over from 3/10 plus 947 caes from 3/11 to equal 1000. then it
shows a balance of 72 let over from 3/11

hope this sounds better

thanks
 
O

Otto Moehrbach

You didn't say anything about what Excel should/could use as the trigger to
fire the automation. For now I'll assume it's any numerical entry made in
Column B below row 1. Excel can do lots for you with this but it must be
told every little detail so I have a question.
Question: Is every entry in Column B ALWAYS 1000 or greater? If not, and
the sum of that entry and the "leftover" (53 in your 3/10 example) is less
than 1000, what do you want to happen?
Another question: What version of Excel are you using? Otto
 
B

Bowmanator

you assumed everything correct, and everything entered in b2 and below will
be greater then 1,000.
 
O

Otto Moehrbach

The macros below do what you want. The first macro is an event macro that
fires whenever an entry is made in Column B. This macro must be placed in
the sheet module of your sheet. To access that module, right-click on the
sheet tab and select View Code. Paste this first macro into that module,
"X" out of the module to return to your sheet. The other 2 macros including
everything from "Option Explicit" and below should be placed in a regular
module. Come back if you need more. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Column = 2 Then
If Target.Row = 2 Then _
Call FirstEntry(Target)
If Target.Row > 2 Then _
Call TheRestEntry(Target)
End If
End Sub

Option Explicit
Dim c As Long
Dim WhatsLeft As Long

Sub FirstEntry(TheCell As Range)
Dim cc As Long
Application.EnableEvents = False
cc = Int(TheCell / 1000)
For c = 0 To cc - 1
TheCell.Offset(c, 3) = 1000
Next c
WhatsLeft = TheCell.Value - cc * 1000
TheCell.Offset(cc, 3) = WhatsLeft
Application.EnableEvents = True
End Sub

Sub TheRestEntry(TheCell As Range)
Application.EnableEvents = False
TheCell.Offset(, 1) = TheCell.Offset(-1, 3)
TheCell.Offset(, 2) = 1000 - TheCell.Offset(, 1)
TheCell.Offset(, 3) = 1000
WhatsLeft = TheCell - TheCell.Offset(, 2)
For c = 1 To 100
If WhatsLeft >= 1000 Then
TheCell.Offset(c, 3) = 1000
WhatsLeft = WhatsLeft - 1000
Else
TheCell.Offset(c, 3) = WhatsLeft
Exit For
End If
Next c
Application.EnableEvents = True
End Sub
 
B

Bowmanator

John, that's almost right on except is it possible for column D to show what
is to make up the 1,000?

example would be that i have 999 left over from 3/15 so on 3/16 i'd start
out with 999 in column C and column D should show that i need 1 from 3/16 to
equal 1,000

thanks
 
B

Bowmanator

John,

that's exactly what i'm looking for, i just have 1 question though.

don't know if i'll explain it right but i'll give it a try.

the formulas work great except when the results are more then two.

example, in the attachment you sent the leftover from C14 and F14
transfered down to C18 like it should, but since there is more than
1 result under the 3/18/2010 entry the final result C21 and F21
dosen't transfer, but if the final balance ended at C19 it will transfer down.

hope it doesn't sound to confussing.

thanks
 
J

John

Hi
You're right, a "bug", the formula I used in column C is no good for this
application.
I need to rethink this over, don't know if I've got time today.
Did you look the macro that Otto Moehrbach sent you, it works very well from
what I can see.
Anyway, I will have a look and see if I can correct the problem. It's the "MIN()
formula in the other cells that is giving me the problem,
I may need to rethink and start new.
Will post back.
Regards
John
 
O

Otto Moehrbach

Ask questions. If you are still unsure of what to do with the macros, you
can send me an email and I'll send you the file I generated for this. It
will have all the macros properly placed. My email is
(e-mail address removed). Remove the "extra" from this email address.
Otto
 
B

Bowmanator

Otto,

i figured out how to insert and run the marcos and it works great but i have
a couple questions for you.

1. what would i need to change in the marcos if i wanted to add more columns?

what it will look like is this
A B C D E F
1 date lot# amount previous crrent total


2. there is a possability that the amount would be less then 1000
is there something i can change? learning is great but tuff.

thanks
 
J

John

Hi Bowmanator
I'm glad to see you're going with Otto's macro. I tried different things but to
no avail.
To crack this one, we would need help from the community if it can be done with
formulas.
You need to go below 1000, that brings more problems, the first one I sent you
will go below 1000 only if the total with the balance is over 1000.
Hope that Otto can fixe that for you.
Let us know if you get it working.
Good luck
John
 
O

Otto Moehrbach

Re your first question. What and where the code does hangs on the location
of the Target cell. In your case, the Target cell is the Amount cell. That
was in Column B. If you want to change that to Column C, change the 2 to a
3 in this line in the first macro:
If Target.Column = 2 Then

Re your second question. That would involve a bit more. Exactly what would
you do, manually, if the amount was less than 1000. Consider both the
situation where the amount plus the WhatsLeft is more than 1000 and less
than 1000. WhatsLeft is the amount in the previous row and 3 columns to the
right of the Target cell (the 53 and 72 in your examples). Otto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top