snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("D2") = "A" Then
OptionButton2.Value = True
ElseIf Range("D2") = "B" Then
OptionButton1.Value = True
ElseIf Range("D2") = "C" Then
OptionButton3.Value = True
End If
End Sub
Private Sub OptionButton1_Click()
If OptionButton1.Value = True Then Sheets("Input").Range("C4").Value = "โรงพยาบาล"
End Sub
Private Sub OptionButton2_Click()
If OptionButton2.Value = True Then Sheets("Input").Range("C4").Value = "โรงเรียน"
End Sub
Private Sub OptionButton3_Click()
If OptionButton3.Value = True Then Sheets("Input").Range("C4").Value = "อนามัย"
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("C4") = "A" Then
OptionButton2.Value = True
ElseIf Range("C4") = "B" Then
OptionButton1.Value = True
ElseIf Range("C4") = "C" Then
OptionButton3.Value = True
End If
End Sub
You do not have the required permissions to view the files attached to this post.
Dim shChn As Boolean
Private Sub OptionButton1_Click()
Application.EnableEvents = False
If shChn Then Exit Sub
If OptionButton1.Value = True Then Sheets("Input").Range("D2").Value = "A"
Application.EnableEvents = True
End Sub
Private Sub OptionButton2_Click()
Application.EnableEvents = False
If shChn Then Exit Sub
If OptionButton2.Value = True Then Sheets("Input").Range("D2").Value = "B"
Application.EnableEvents = True
End Sub
Private Sub OptionButton3_Click()
Application.EnableEvents = False
If shChn Then Exit Sub
If OptionButton3.Value = True Then Sheets("Input").Range("D2").Value = "C"
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
shChn = True
If Target.Address(0, 0) = "D2" Then
Select Case Me.Range("c4").Value
Case "โรงพยาบาล"
Me.OptionButton1.Value = True
Case "โรงเรียน"
Me.OptionButton2.Value = True
Case "อนามัย"
Me.OptionButton3.Value = True
End Select
End If
shChn = False
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim o As OLEObject
If Target(1).Address = "$D$2" Then
[C4].Value = Application.VLookup([D2], [Data!A1:B5], 2, 0)
For Each o In Me.OLEObjects
o.Object.Value = o.Object.Caption = [C4]
Next
End If
End Sub
Private Sub OptionButton1_Click()
Application.EnableEvents = False
If OptionButton1.Value Then [C4] = OptionButton1.Caption
Application.EnableEvents = True
End Sub
Private Sub OptionButton2_Click()
Application.EnableEvents = False
If OptionButton2.Value Then [C4] = OptionButton2.Caption
Application.EnableEvents = True
End Sub
Private Sub OptionButton3_Click()
Application.EnableEvents = False
If OptionButton3.Value Then [C4] = OptionButton3.Caption
Application.EnableEvents = True
End Sub
You do not have the required permissions to view the files attached to this post.