Excel - Detectar clic en una celda

 
Vista:
Imágen de perfil de JuanC

Detectar clic en una celda

Publicado por JuanC (1237 intervenciones) el 16/02/2010 16:38:05
Hace mucho que no hago un aporte personal al foro...
Aquí va algo 'curioso, interesante y útil'

Option Explicit
Option Private Module
'//------------------------------------
'//By JuanC - 10 de Septiembre de 2007
'//------------------------------------
Private Declare Function apiGetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Private Declare Function apiGetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer
Private Declare Function apiGetKeyState Lib "user32" Alias "GetKeyState" (ByVal nVirtKey As Long) As Integer
Private Const VK_LBUTTON = &H1
Private Const VK_CONTROL = &H11
Private Const VK_SHIFT = &H10
Private Type POINTAPI
x As Long
y As Long
End Type
Public Function Click_In_Rng(ByVal Rng As Range) As Boolean
Dim R As Range
Dim pos As POINTAPI
On Error Resume Next
Click_In_Rng = False
Call apiGetCursorPos(pos)
Set R = ActiveWindow.RangeFromPoint(pos.x, pos.y)
If Not R Is Nothing And Selection.Count = 1 Then
If Not Intersect(R, Rng) Is Nothing Then '//Rango
If apiGetAsyncKeyState(VK_LBUTTON) Then '//Clic
'If apiGetKeyState(VK_CONTROL) And &H80 Then '//Ctrl
' If apiGetKeyState(VK_SHIFT) And &H80 Then '//Shift
Click_In_Rng = True
' End If
'End If
End If
End If
End If
Set R = Nothing
End Function

Saludos, desde Baires, JuanC
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder