Pop up function for calculation

afs24

Board Regular
Joined
Sep 26, 2002
Messages
237
I'm trying to create, in a form, a pop up where I can punch in two number to get a percentage. Say I want to know what percentage 5000 is of 25000. How would I do this and could you give me an example?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi afs24,

First put a button on the form from which you want to display the popup, with code like:
Code:
Private Sub CmdPopup_Click()

    DoCmd.OpenForm ("Frm_Popup")

End Sub

adjust the names as necessary.

You will then need a new form (frm_popup) with three textboxes (TxtNumerator, TxtDenominator, and TxtPercent) as well as a button (CmdCalculate).

Right click on the button and create an event, and enter this code:
Code:
Private Sub CmdCalculate_Click()

    If IsNull(TxtDenominator) Or TxtDenominator = 0 Then
        MsgBox ("Please complete 'of:' field on this form")
        Exit Sub
    End If
    
    TxtPercent = Format(TxtNumerator / TxtDenominator, "0.00%")

End Sub

Here's an example:
http://theillumni.com/posts/pop-up_calc.zip

HTH,
 
Upvote 0

Forum statistics

Threads
1,221,551
Messages
6,160,460
Members
451,648
Latest member
SuziMacca

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