Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro For Stock Control

Why not have a transaction sheet

initialize on hand stock
Stock Item1 50
Stock Item2 100
Stock Item3 25
Stock Item4 10

Now transactions are added on each line
Stock Item1 -1
Stock Item2 2
Stock Item2 -1
Stock Item3 8
Stock Item1 -2

then on your original sheet have your stock item listed in column 1. In
column2

=Sumif(Transaction!A:A,A2,Transaction!B:B)

and drag fill down.

You could of course reverse the order, and insert a line at the top when
adding a transation. Additionally, you might put in a date column.

This gives you a history. If you have thousands of items, then it probably
isn't feasible, but then using excel probably isn't the best choice either.

If you want to go with what you describe, in the sheet module where you have
commandbutton1 (to increase) and commandbutton2 (to decrease) - entries are
made in A2:B2 of that sheet.

Increment:

Private Sub CommandButton1_Click()
Dim rng as Range, res as Variant
set rng = Range(cells(3,1),cells(rows.count,1).End(xlup))
res = application.Match(Range("A2").Value,rng,0)
if not iserror(res) then
rng(res).offset(0,1).Value = rng(res).offset(0,1).Value _
+ Range("B2").Value
Range("A2:B2").Clear contents
else
msgbox Range("A2").Value & " not found"
End if


Decrement:

Private Sub CommandButton2_Click()
Dim rng as Range, res as Variant
set rng = Range(cells(3,1),cells(rows.count,1).End(xlup))
res = application.Match(Range("A2"),Value,rng,0)
if not iserror(res) then
rng(res).offset(0,1).Value = rng(res).offset(0,1).Value _
- Range("B2").Value
Range("A2:B2").Clear contents
else
msgbox Range("A2").Value & " not found"
End if

--
Regards,
Tom Ogilvy




"Chacky" wrote:

Does anyone have a macro for simple stock control?

Here is how I envisage it working

The worksheet would have 2 columns - column 1 with a stock code, column 2
with a quantity.

The quantity in column 2 needs to be updated when stock is added or taken
away.

I think 2 macros would be required, 1 to add to stock and 1 to remove from
stock.

The stock code and quantity to be added or removed would be entered in
specific cells at the top of the worksheet.

The relevant macro (adding or removing stock) would be run, the macro would
search for the stock code in column 1 and adjust the quantity in column 2.

Doe this sound possible?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
stock control help sonia Excel Discussion (Misc queries) 1 March 16th 09 12:10 PM
stock control cliff Excel Discussion (Misc queries) 1 May 18th 07 01:46 PM
Stock control formulas, counting and reporting remaining stock santaviga Excel Programming 2 October 23rd 06 01:34 PM
Stock control..help please Terry Excel Discussion (Misc queries) 0 January 13th 05 07:16 PM
stock control stiv Excel Programming 3 February 5th 04 05:03 AM


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"