zeynab

New Member
Joined
Mar 26, 2016
Messages
1
How can I create a command button that, when pressing it, will calculate the area of a rectangle by getting values from the user at run time with the help of two input boxes (one for length and one for width) and stores the result in cell A1. This should be done in Sheet4
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
By input box do you mean 2 cells or a pop up window?

If a pop-up window, you have to draw a userform, not that easy if you now nothing about VBA. An option would be to write the values in 2 cells when pressing ok and the formula in Sheet4!A1

Code:
=cell(length)*cell(width)

or the VBA code could be

Code:
Sheet("sheet4").range("A1")=textbox1.value*textbox2.value

but in either case you would not need a button
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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