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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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