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
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,176
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
 

Watch MrExcel Video

Forum statistics

Threads
1,108,855
Messages
5,525,227
Members
409,637
Latest member
LT TASL

This Week's Hot Topics

Top