snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$A$2" Then
With ActiveSheet.Calendar1
.Visible = True
.Top = ActiveCell.Offset(0, 0).Top
.Left = ActiveCell.Offset(0, 1).Left
End With
Else
End If
If Target.Address = "$B$2" Then
With ActiveSheet.Calendar1
.Visible = True
.Top = ActiveCell.Offset(0, 0).Top
.Left = ActiveCell.Offset(0, 1).Left
End With
Else
End If
If Target.Address = "$D$2" Then
With ActiveSheet.Calendar1
.Visible = True
.Top = ActiveCell.Offset(0, 0).Top
.Left = ActiveCell.Offset(0, 1).Left
End With
Else
ActiveSheet.Calendar1.Visible = False
End If
Application.EnableEvents = True
End Sub
With ActiveSheet.Calendar1
.Visible = True
.Top = ActiveCell.Offset(0, 0).Top
.Left = ActiveCell.Offset(0, 1).Left
if target.value <> "" then
.value = target.value
end if
End With