custom box

lougalea

New Member
Joined
Jun 28, 2012
Messages
40
Can the following equations be made in a pop up box for Excel ver.2010.Just enter a value in a entry box and the result is automatically calculated

area = PI * (radius) * (radius)
radius = (diameter / 2)
diameter = 2 * radius
diameter = circumference / PI
circumference = PI * diameter
circumference = PI * (radius * 2)
sphere surface area = 4 * PI * (radius * radius)
sphere volume = 4/3 * PI * (radius * radius * radius)

Cheers
Lou
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi and welcome to the forum.

You would need to know an initial value. The code below assumes you know the radius.

Open Excel,
Press Alt+F11.
Place the code below in the ThisWorkbook module and press F5 to run..

Code:
[COLOR=darkblue]Sub[/COLOR] test()
   [COLOR=darkblue]Dim[/COLOR] r [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Double[/COLOR]   [COLOR=green]'radius[/COLOR]
   [COLOR=darkblue]Dim[/COLOR] pi [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Double[/COLOR]
   [COLOR=darkblue]Dim[/COLOR] txt [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
   
   pi = 4 * Atn(1)
   r = Application.InputBox("Enter Radius", Type:=1)
   [COLOR=darkblue]If[/COLOR] r = 0 [COLOR=darkblue]Then[/COLOR]
      MsgBox "Please enter a valid number!"
      [COLOR=darkblue]Exit[/COLOR] [COLOR=darkblue]Sub[/COLOR]
   [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
   
   [COLOR=green]'build up the output message[/COLOR]
   txt = "Area = " & pi * (r ^ 2) & vbCrLf
   txt = txt & "Radius = " & (2 * r) / 2 & vbCrLf
   txt = txt & "Diameter = " & 2 * r & vbCrLf
   txt = txt & "Circumference = " & pi * 2 * r & vbCrLf
   txt = txt & "Sphere Surface Area = " & 4 * pi * r ^ 2 & vbCrLf
   txt = txt & "Sphere Volume = " & (4 / 3) * pi * r ^ 3
   
   MsgBox txt
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,206,758
Messages
6,074,768
Members
446,085
Latest member
Grunter

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