adamswalwell said:
Therefore is there anybody out there who has the code to which I am able to add 2 values to a Macro button. 1 which will add to a reciept worksheet the price of a portion of chips and the detailsm a portion of chips and deduct the value of 1 from a stock intake worksheet.
Hello, adamswalwell
Welcome to the Board !
here a little example of macro
Code:
Sub test()
Range("stocktotal") = Range("stocktotal") + 1
End Sub
this assumes you have named your range
else you can use something like
Sheets("stock").Range("A1") = ...
if your question was also about how to create buttons and assign macros to them
If you don't already have the "Forms" toolbar active, click on Tools>Customize>Toolbars and check "Forms". The toolbar will appear on your screen; drag it down to the bottom of your screen to anchor it.
Click on the Button icon, and drag out a button on the screen. When you release the left mouse button, an "Assign Macro" dialogue box will appear. Highlight your macro "test", and click OK. The macro will now be assigned to that button.
..........................................
If the button is already created:
If your button is made with the Forms Toolbar
start the
Visual
Basic
Editor (via Menu Tools, Macro or press ALT+F11).
On the Insert menu in the
VBE, click Module. (if necessary)
In the module (the white area at the right), paste the following code:
Code:
Sub test1()
MsgBox "Hello"
End Sub
right click on the button
choose "assign macro"
choose macro
test1
clicking on the button you will get "Hello"
if you're button is created with the Controls Toolbar
choose "show programm code" from the rightclick menu
you will get this
Code:
Private Sub CommandButton1_Click()
End Sub
where you can fill in your macro
Code:
Private Sub CommandButton1_Click()
MsgBox "Welcome to the Board",48,"HELLO"
End Sub
kind regards,
Erik