Add two cells values on two different worksheets

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,251
Office Version
  1. 2007
Platform
  1. Windows
Hi,

I wish to add a code on a command button that will add two cell values.
The command button will be on Worksheet 2
Some info for you.

Worksheet 1 cell value A20 to be added to value currently in Worksheet 2 cell R46
Worksheet 1 cell value B25 to be added to value currently in Worksheet 2 cell T50

Example
A20 £125.00 & R46 £57.00 add these together so now cell value in R46 shows £182.00

B25 74 & T50 27 add these together so cell value in T50 shows 101

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try:
VBA Code:
Sub AddCells()
    Range("R46") = Range("R46") + Sheets(1).Range("A20")
    Range("T50") = Range("T50") + Sheets(1).Range("B25")
End Sub
 
Upvote 0
Hi,
When i run the code the command button just blinks & nothing happens in the cell that should be updated.

If i remove the values from the cells that should be updated then run the code one then shows £0.00 & the other 0
 
Upvote 0
I tested the code and it worked exactly as you requested.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of both sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here.
 
Upvote 0
I placed values A20 and B25 of Sheet1, clicked the button on Sheet2 and the macro worked as requested.
 
Upvote 0
Well thanks for your time but im lost.

Im using the same file but now when i run it on sheet 2 i get a 0 & the correct number in the other cell.
Each time i run the code the 0 stays the same but the value in the other cell it doubled each time.

Many thanks but sorry to waste your time
 
Upvote 0
Click here for your file. Click the button on Sheet2. Is it working for you?
 
Upvote 0

Forum statistics

Threads
1,215,740
Messages
6,126,582
Members
449,319
Latest member
iaincmac

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