has a number key been pressed?

e211898

New Member
Joined
Aug 28, 2010
Messages
14
I would like to call a message box only after a number key (1234567890) has been pressed. what is the event and code that i need to use? the code i am trying to modify is
Code:
Private Sub ib_payout_Change()
    If MsgBox("Please use good judgement when changing the payout price for an order. Are you sure you wish to change this price?", vbOKCancel, "Change Price") = vbOK Then
        Exit Sub
    Else
        ib_total_form.Show
        Exit Sub
    End If
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
What kind of control is ib_payout?
Is it on a userform or on a worksheet?
If so, is ib_total_form a different userform than the one that contains the ib_payout control?

Where is the current pay out price stored?
Is that the place where you want the user's (wisely judged) new price to be put?

Also, have you looked at the KeyPress and KeyDown events?
 
Upvote 0
Hi e211898,

Try the event procedure macro on the relevant tab in question:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
        
    If IsNumeric(Target.Value) = True Then
        If (MsgBox("Please use good judgement when changing the payout price for an order." & vbNewLine & "Are you sure you wish to change this price?", vbQuestion + vbYesNo, "Change Price")) = vbYes Then
            ib_total_form.Show
        Else
            Exit Sub
        End If
    End If

End Sub

To install this macro follow this four steps:

1. Copy my code above to clipboard (Ctrl + C)

2. Right click on the sheet you want this code to run from and from the shortcut menu select View Code

3. Paste my code (Ctrl + P) from step one above into the blank module

4. From the VBE menu click File and then Close and Return to Microsoft Excel

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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