ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Ãö©ó ¦Û°ÊÂê©wÀx¦s®æ

[µo°Ý] Ãö©ó ¦Û°ÊÂê©wÀx¦s®æ

¥Î¤F¥H¤UVBA
¥»·Q¿é¤J¸ê®Æ«á ¦Û°ÊÂê©wÀx¦s®æ
¥Î¦b´¶³qÀx¦s®æ¬O¥i¥H¥¿±`¨Ï¥Î

¦ý¦pªG¤w¸g¦X¨ÖªºÀx¦s®æ
¨S¦³¿é¤J¸ê®Æ¤w¸g¦Û°ÊÂê©w

½Ð«ü±Ð
Thanks
------------------------------------------------

Private Sub Worksheet_SelectionChange
ActiveSheet.Unprotect
¡@ Target.Locked = False
¡@¡@¡@¡@On Error Resume Next
¡@¡@¡@¡@¡@¡@¡@¡@If Target <> "" Then
¡@¡@¡@¡@¡@¡@Target.Locked = True
¡@¡@¡@¡@ActiveSheet.Protect Contents:=True
¡@¡@¡@End If
End Sub

¥»©«³Ì«á¥Ñ luhpro ©ó 2013-10-18 01:30 ½s¿è
¥Î¤F¥H¤UVBA
¥»·Q¿é¤J¸ê®Æ«á ¦Û°ÊÂê©wÀx¦s®æ
¥Î¦b´¶³qÀx¦s®æ¬O¥i¥H¥¿±`¨Ï¥Î

¦ý¦pªG¤w¸g¦X¨ÖªºÀx¦s®æ
...
kkttin µoªí©ó 2013-10-17 12:43

·í¼ÐªºÀx¦s®æ¬O­Ó¦X¨ÖªºÀx¦s®æ®É (.Count > 1),
§ì¨ú¸ê®Æ­n§ï¥Î .Value2(1, 1)
§_«h¤£¬Oµo¥Í¿ù»~(.Value)´N¬O±o¨ìªÅ­È(.Text)
¤S¦]¬°§A¦³¤@¦æ On Error Resume Next(µo¥Í¿ù»~®É©¿²¤¸Ó¿ù»~,§ï±q¤U¤@¦æ«ü¥O¶}©lÄ~Äò°õ¦æ),
¬G¦Ó´Nµo¥Í§A¤£·Q­nªºµ²ªGÅo.
§ï¦¨¦p¤U§Y¥i :
  1.   With Target
  2.     .Parent.Unprotect
  3.     .Locked = False
  4.     If .Count = 1 Then
  5.       If .Value <> "" Then
  6.         .Locked = True
  7.         .Parent.Protect Contents:=True
  8.       End If
  9.     Else
  10.       If .Value2(1, 1) <> "" Then
  11.         .Locked = True
  12.         .Parent.Protect Contents:=True
  13.       End If
  14.     End If
  15.   End With
½Æ»s¥N½X
¨S°O¿ùªº¸Ü¦b Office 2000 ®É¤£·|¦³³o­Ó°ÝÃD, (¥i¥H¥Î .Value ©Î . Text ¥¿±`§ì¨ì¦X¨Ö«áªº­È)
¦ü¥G¬O¨ì 2003 ®É§ïªº(§Ú®a¸Ì¥Îªºª©¥»),
§Úı±o³o¦³ÂI¦h¦¹¤@Á|,
¬JµMÀx¦s®æ¦X¨Ö«á¥u¯à«O¯d¤@­Ó­È,
¨º¦h¥X¨º¨Ç .Value2(1, 2), .Value2(1, 3)... ¨SÔ£·N¸q.(®Ú¥»µLªk¨Ï¥Î)

§óÁV¿|ªº¬O §Ú­è­è¸ÕµÛ½á¤©­Ó­Èµ¹ Target.Value2(1, 2) , (¹ð¸Õ¤£²n)
¥¦·|µo¥ÍÄY­«¿ù»~¥Bª½±µÃö³¬ Excel.  O.O"
(­Y¹ï [C4].Value2(1, 2) ½á­È¨S°ÝÃD, ¦ý¹ï Target.Value2(1, 2) ½á­È´N·|¥X¤j¿ù)

TOP

¦^´_ 2# luhpro
¨S¬Ý¹Lvalue2³oºØ¥Îªk­C¡A°Ñ¦Ò http://support.microsoft.com/kb/213719/zh-tw

§Úı±o1#ªº°ÝÃD¬O
Target¬°¦h­ÓÀx¦s®æ(¦X¨ÖÀx¦s®æ¤]ºâ¦h­Ó)®É¡A
If Target <> "" Then ¤¤ªº Target ¤ñ¸û®É·|¦Û°Ê¨Ï¥ÎÄÝ©Ê .value¡A
¦ý¬O¦¹®Éªº Target.value  ¬°¤@ value °}¦C¡A¬GµLªk¤ñ¸û¡Aµo¥Í¿ù»~
¦Ó¥Ñ©ó¥[¤W On Error Resume Next ¾É­P¥h°õ¦æ¤U¤@¦æªºÂê©w¡AÀ³§ï¬°¡G
  1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  2.   ActiveSheet.Unprotect
  3.   Target.Locked = False
  4.   
  5.   If Target.Cells(1).Value <> "" Then
  6.     Target.Locked = True
  7.     ActiveSheet.Protect Contents:=True
  8.   End If
  9. End Sub
½Æ»s¥N½X
¸É¥Rµ¹1#¡Aµo¥Íerror®É¤£­nÀH«K¥[On Error Resume Next¥h©¿²¤¥¦¡A°£«D§A©ú½Tªºª¾¹D¥¦¬O¬Æ»ò¿ù»~¡A¬O¤£¬O¥i¥H©¿²¤¡C

TOP

¦^´_  luhpro
¨S¬Ý¹Lvalue2³oºØ¥Îªk­C¡A°Ñ¦Ò http://support.microsoft.com/kb/213719/zh-tw

§Úı±o1# ...
stillfish00 µoªí©ó 2013-10-18 10:36

§A»¡ªº¤]¬O¹ïªº.

¦ý value2 µ´¹ï¥i¥H¥Î,(2# »P 3 # »¡ªº¬O¦P¤@­ÓªFªF)
¦]¬°¨º¬O¦b "°Ï°ìÅܼÆ" µøµ¡¤¤À˵ø Target Àx¦s®æ¸ê®Æ®É¬Ý¨ìªº¤º®e(«ö Target ÅܼƥªÃ䪺 + ³v¼hÀ˵ø´N¥i¬Ý¨ì),
¤]¬O Excel VBA ¯u¥¿Àx¦s¬ÛÃö¸ê®Æªº§Î¦¡.

§A»¡ªºÀ³¸Ó¬O Excel VBA ¹ïÀ³¨ì value2 ªº¥t¤@ºØ¥Îªk - ¥Î Value. (¦p¦P Value »P Text ¤@¼Ë³£¬O¹ïÀ³¨ìÀx¦s®æªº­È)

·íµM, ­Y¯u°Ê¨ì "°Ï°ìÅܼÆ" µøµ¡¤º®e³o­Ó³¡¥÷,
¦³®É½T¹ê·|µo¥ÍµLªk¹w´Áªº¿ù»~,
¦]¬°,Excel VBA ¨ä¹ê¦³«Ü¦h¦a¤è°µªº³£¤£°÷§¹µ½, (¦³ÂI¹L¨º­Ó + ªº¤H´N·|ª¾¹D, ¤@­ÓÀx¦s®æ¸Ì¥]§tªºªFªFÁÙ¯u¬O¦h°Ú...)
¦³¥i¯à·|µo¥Í "³]­pªÌ©ÒµLªk¹w´Áªº¿ù»~" .(´N¹³§Ú 2# ©Ò´£¨ìªº¨º­Ó)

TOP

        ÀR«ä¦Û¦b : ·O´d¨S¦³¼Ä¤H¡A´¼¼z¤£°_·Ð´o¡C
ªð¦^¦Cªí ¤W¤@¥DÃD