Web Hosting Talk







View Full Version : Excel / VB Function


webdirect
04-02-2007, 01:54 PM
Hey Guys

This might seem a slightly weird question however... I'm trying to build a very basic stock control system in Excel. What I want is to have the product name in A1, Stock Required in B1, and number in stock in C1.

Now say C1 starts at 10, the boss wants a button to click to reduce the value by 1 everytime it is clicked.... Now obviously you can't use in C1 =C1-1 because that is a circular reference...

Anyone got an idea about the VB code to use for this macro ?

Cheers

jimpoz
04-05-2007, 02:40 PM
Have the button point to this macro:
Sub MyMacro()
Dim temp
temp = Range("C1").Value2
Range("C1").Activate
If temp <> 0 Then ActiveCell.Formula = temp-1
End Sub