Theo mình dùng Validation, không cần phím tắc thế. Bạn xem được không, nếu cần vậy thì tính tiếpEm có 1 ví dụ này muốn nhờ AC viết dùm em code tạo 1 phím tắt làm hiện danh sách hàng hoá để chọn mã hàng.
(câu hỏi cụ thể trong file đính kèm nhé!)
Theo mình dùng Validation, không cần phím tắc thế. Bạn xem được không, nếu cần vậy thì tính tiếp
Cám ơn viehoai nhiều! Nhưng các này thì em làm được rùi. Em muốn tạo cách kia để nó hiển thị thêm thông tin lựa chọn nữa mà!? viehoai và AC xem có cách khác không giúp em nhé!?
Theo như câu mầu màu đỏ trên, ý của bạn là sao?
Để hiện ra UserForm chẳng có gì khó (UserForm.Show thôi)... Có điều cái khó nhất là làm sao cho UserForm hiện đúng ngay cell mà ta đang chọn mới là vấn đềCám ơn viehoai nhiều! Nhưng các này thì em làm được rùi. Em muốn tạo cách kia để nó hiển thị thêm thông tin lựa chọn nữa mà!? viehoai và AC xem có cách khác không giúp em nhé!?
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Sub FormPosition(ByRef frmForm As Object, ByVal rCell As Range)
Dim PointsPerPixelX As Double
Dim PointsPerPixelY As Double
Dim x As Long, y As Long
Dim rng As Range
Dim bFound As Boolean
Set rCell = rCell(1, 1)
PointsPerPixelX = 72 / GetDeviceCaps(GetDC(0), 88)
PointsPerPixelY = 72 / GetDeviceCaps(GetDC(0), 90)
ReleaseDC 0, GetDC(0)
For x = Int(Application.Left / PointsPerPixelX) To Int(Application.Left / PointsPerPixelX + Application.Width / PointsPerPixelX)
For y = Int(Application.Top / PointsPerPixelY) To Int(Application.Top / PointsPerPixelY + Application.Height / PointsPerPixelY)
Set rng = Application.Windows(1).RangeFromPoint(x, y)
If Not (rng Is Nothing) Then
bFound = True
Exit For
End If
Next
If bFound Then Exit For
Next
frmForm.StartUpPosition = 0
frmForm.Top = y * PointsPerPixelY + (rCell.Top - rng.Top)
frmForm.Left = x * PointsPerPixelX + (rCell.Left - rng.Left)
frmForm.Show vbModeless
End Sub
Sub Auto_Open()
Application.OnKey "{F4}", "ShowForm"
End Sub
Sub ShowForm()
If Not Intersect(ActiveCell, Range("A2:A20")) Is Nothing And Selection.Count = 1 Then
DMHH.Hide
DMHH.StartUpPosition = 0
FormPosition DMHH, ActiveCell.Offset(, 1)
DMHH.Show
End If
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ActiveCell.Value = ListBox1.List(ListBox1.ListIndex)
Unload Me
End Sub
Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
ActiveCell.Value = ListBox1
Unload Me
End If
End Sub
Sub Auto_Open()
Application.OnKey "{F4}", "ShowForm"
End Sub
DIỄN ĐÀN GIẢI PHÁP EXCEL Group 1
DIỄN ĐÀN GIẢI PHÁP EXCEL Group 2