ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   pop-up calculator (https://www.excelbanter.com/excel-programming/402678-pop-up-calculator.html)

Anthony

pop-up calculator
 
how do I set up to click on cell and number pad shows up like ms money

Chip Pearson

pop-up calculator
 
The simplest way is to use code like the following in the module of the
worksheet that should intercept the DoubleClick event. Right click the
sheet's tab and choose View Code. Paste the following code into that module.
Change the "A1:A10" to the range that, when double-clicked, should bring up
the calculator.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Not Application.Intersect(Me.Range("A1:A10"), Target) Is Nothing Then
Cancel = True
Shell "Calc.exe"
End If
End Sub

With this code, the calculator will be obscured by the main Excel window. A
better solution is to make the Calculator window a child of the main Excel
window. With the following code, the calculator will float above the Excel
worksheet windows.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function SetParent Lib "user32" ( _
ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim XLHWnd As Long
Dim CalcHWnd As Long

If Not Application.Intersect(Me.Range("A1:A10"), Target) Is Nothing Then
Cancel = True
Shell "Calc.exe"
XLHWnd = Application.Hwnd
CalcHWnd = FindWindow("SciCalc", "Calculator")
If CalcHWnd < 0 Then
SetParent CalcHWnd, XLHWnd
End If
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)




"Anthony" wrote in message
...
how do I set up to click on cell and number pad shows up like ms money




All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com