Button with macro to add 1 to a cell in another sheet

Bolter LAC

Board Regular
Joined
Aug 13, 2008
Messages
140
I have a button on Sheet 2 with the following macro.
Code:
Sub Button1_Click()
   Range("B3").Value = Range("B3").Value + 1
End Sub
I want to change this so that cell B3 in Sheet 1 increases by one and not the worksheet with the button. What do I have to add to the code to facilitate this?

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Bolter LAC,


The following code will add 1 to the present value in worksheet Sheet1, each time the button in worksheet Sheet2 is pressed.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Code:
Sub Button1_Click()
   Worksheets("Sheet1").Range("B3").Value = Worksheets("Sheet1").Range("B3").Value + 1
End Sub
 
Upvote 0
Try

Code:
Sub Button1_Click()
With Sheet1
   .Range("B3").Value = .Range("B3").Value + 1
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,642
Messages
6,125,987
Members
449,276
Latest member
surendra75

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