
เอาไปวางทั้งหมดไม่ได้ครับ
ที่ส่งให้มันเป็นตัวอย่างเท่านั้น
ถ้า Password คือ Secret ก็ให้ปลดด้วย Password นี้ก่อน
ถ้า Password คือ ANUSARA ก็ให้ปลดด้วย Password นี้ก่อน
การปลด ก็เช่น
ActiveSheet.Unprotect Password:="ANUSARA"
ข้างบนนี้วางไว้ก่อน Code ที่ต้องการเปลี่ยนแปลงใน Sheet ที่กำลังทำงาน
การ Protect ใหม่ก็เช่น
ActiveSheet.Protect Password:="ANUSARA"
ข้างบนนี้วางไว้หลังจากมีการเปลียนแปลงเรียบร้อยแล้ว
แค่ 2 บรรทัดที่ให้ไปนี้ไปใช้ก็น่าจะพอครับ ตัวอย่างการวาง Code ตามด้านล่างครับ
Code: Select all
Private Sub ComboBox1_Change()
ActiveSheet.Unprotect Password:="ANUSARA"
If Range("xSizeEx") = "Custom" Then
xSizeEx = InputBox(Prompt:="Please Enter Custom Size Please.", Title:="PLEASE ENTER CUSTOM SIZE", Default:="")
Range("xSizeEx") = xSizeEx
Range("xSizeEx").NumberFormat = "General "" (Custom)"""
Else
Range("xSizeEx") = Range("xSizeEx")
Range("xSizeEx").NumberFormat = "General"
End If
ActiveSheet.Protect Password:="ANUSARA"
End Sub