Using a command button to update a cell value

Adrian1

Board Regular
Joined
Dec 30, 2003
Messages
126
Hi you clever people,

Could someone please tell me how I would make a command button do the following:

Make the value of merged cells b7:d7 equal the value of merged cells b6:d6 plus one?

When pressed, I want the button to populate cell range b7:d7 with the value plus one in (merged cells) b6:d6.

I hope this makes sense. :rolleyes:
 
Code:
Private Sub CommandButton1_Click()
 Range("B7") = Range("b6").Value + 1
End Sub

I tried this, and it worked just using the first merged cell address.
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
In general it's always a good idea to use range names when referring to cells in macros if you'll be modifying the spreadsheet. Macros don't adjust for relative references like spreadsheet formulas do. So if you insert a row above your data, the macro will no longer work.
 
Upvote 0
I had a similar issue when dealing with merged cells in 97. Try this for kicks & giggles:

Code:
Private Sub CommandButton5_Click() 
Range(" b7").Value = Range("index1").Value + 1 
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,329
Messages
6,124,301
Members
449,149
Latest member
mwdbActuary

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