ให้ระบบแจ้งว่าต้องการเปลี่ยนแปลงหรือไม่ ตรวจสอบอย่างไรดีครับ โดยที่ พอคีย์ ColumnA ระบบจะถามก่อนที่ข้อมูลใน ColumnA จะเปลี่ยนแปลง รบกวนด้วยครับ
Code: Select all
If Target.Column = 1 Then
With Sheets("Á.¤.")
Set rCheck = .Range("A1", .Range("A" & Rows.Count).End(xlUp))
End With
With Sheets("Data")
Set Rng = .Range("A1", .Range("H" & Rows.Count).End(xlUp)) 'Range H ¤×Í Column ÊØ´·éÒ·Õè´Ö§
End With
ColName = 2
ColAmount = 3
ColIDMKT = 4
ColNameMKT = 5
ColBranch = 6
ColPhone = 7
lng = Application.CountIf(Rng.Resize(, 1), Target)
If lng >= 1 Then
Target.Offset(0, 1) = Application.VLookup(Target, Rng, ColName, 0)
Target.Offset(0, 2) = Application.VLookup(Target, Rng, ColAmount, 0)
Target.Offset(0, 5) = Application.VLookup(Target, Rng, ColIDMKT, 0)
Target.Offset(0, 6) = Application.VLookup(Target, Rng, ColNameMKT, 0)
Target.Offset(0, 8) = Application.VLookup(Target, Rng, ColBranch, 0)
Target.Offset(0, 9) = Application.VLookup(Target, Rng, ColPhone, 0)
Target.Offset(0, 3).Activate 'ä»·Õè ColumnD
Else
'¶éÒäÁèÁÕã¹°Ò¹¢éÍÁÙÅ
MsgBox ("àÅ¢·ÕèºÑªÕ¹ÕéäÁèÁÕã¹°Ò¹¢éÍÁÙÅ")
Target.Offset(0, 0).Activate
Target.Offset(0, 1) = "Êѹ¹Ô°Ò¹ÇèÒ»Ô´ºÑªÕáÅéÇ"
Target.Font.Color = vbRed
Target.Font.Bold = True
Target.Offset(0, 2) = ""
Target.Offset(0, 5) = ""
Target.Offset(0, 6) = ""
Target.Offset(0, 8) = ""
Target.Offset(0, 9) = ""
End If