|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
請教一下 下面代碼 那一段是控制單元格的
代碼是隨便點一個單元格都呼出窗體, 假如我只需要要在C列點擊單元格時才呼出窗體,這個代碼應該改哪里呢, 請教一下
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lHwnd As Long
Dim lDC As Long
Dim lCaps As Long
Dim lngLeft As Long
Dim lngTop As Long
Dim sngPiexlToPiont As Single
Const lLogPixelsX = 88
lDC = GetDC(0)
lCaps = GetDeviceCaps(lDC, lLogPixelsX)
sngPiexlToPiont = 72 / lCaps * (100 / ActiveWindow.Zoom)
lngLeft = CLng(ActiveWindow.PointsToScreenPixelsX(0) + (Target.Offset(1, 0).Left / sngPiexlToPiont))
lngTop = CLng(ActiveWindow.PointsToScreenPixelsY(0) + (Target.Offset(1, 0).Top / sngPiexlToPiont))
UserForm1.StartUpPosition = 0
lHwnd = FindWindow(vbNullString, UserForm1.Caption)
MoveWindow lHwnd, lngLeft, lngTop, 240, 180, True
UserForm1.Show 0
End Sub
|
|