Page 1 of 1

เมื่อคลิกปุ่มแล้วให้ไปดูว่าเคอร์เซอรอยู่ที่ คอลัม G18:1000 ไหม

Posted: Sun Aug 02, 2020 7:12 am
by yodpao.b
เมื่อคลิกปุ่มแล้วให้ไปดูว่าเคอร์เซอร ActiveCell อยู่ที่ คอลัม G18:1000 ไหม
1.JPG
ดังรูปด้านบน จะเห็นว่า เคอร์เซอร ActiveCell อยู่ที่ คอลัม G18
ถ้าอยู่ให้ทำงานต่อ ถ้าไม่อยู่ให้ออกจากการทำงาน

ผมทำถูกต้องแค่ เซล G18 ครับ
ไม่รู้ว่าให้ตรวจสอบลงไปจาก g18 ยังไง
code ที่ใช้งาน

Code: Select all

Sub Macro1()
    

    If ActiveCell <> Range("G18") Then
        MsgBox "xxxxxxx", vbCritical
    Exit Sub
    End If
    MsgBox "dddddddd ¡è͹", vbCritical

    
End Sub

Re: เมื่อคลิกปุ่มแล้วให้ไปดูว่าเคอร์เซอรอยู่ที่ คอลัม G18:1000 ไหม

Posted: Sun Aug 02, 2020 7:39 am
by snasui
:D ตัวอย่าง Code ครับ

Code: Select all

'Other code
If Intersect(ActiveCell, Range("G18:G1000")) Is Nothing Then
    MsgBox "xxxxxxx", vbCritical
    Exit Sub
End If
'Other coode

Re: เมื่อคลิกปุ่มแล้วให้ไปดูว่าเคอร์เซอรอยู่ที่ คอลัม G18:1000 ไหม

Posted: Sun Aug 02, 2020 7:56 am
by yodpao.b
ขอบคุณครับได้ตามต้องการเลย