pop-up calculator

  • Thread starter Thread starter Anthony
  • Start date Start date
A

Anthony

how do I set up to click on cell and number pad shows up like ms money
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top