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

Worksheet_SelectionChange ¤Î Worksheet_Change

Worksheet_SelectionChange ¤Î Worksheet_Change

Worksheet_SelectionChange ¤Î Worksheet_Change

½Ð°Ýµ{¦¡¤¤¦P®É¨Ï¥Î Worksheet_SelectionChange  ¤Î Worksheet_Change ®É
¦p¦ó¦b§ó§ïÀx¦s®æ¤º®e®É, ¥uIJµoWorksheet_Change ¨Æ¥ó
¹Á¸Õ¹L¦bµ{¦¡¶}©l¥[¤W Application.EnableEvents = False
µ²§À¥[¤WApplication.EnableEvents = true
½Ð«ü±Ð

¥»©«³Ì«á¥Ñ lpk187 ©ó 2017-5-30 00:16 ½s¿è

¦^´_ 1# enoch

·í§A¦P®É¨Ï¥ÎWorksheet_Change©M Worksheet_SelectionChange®É¡A
¥u­n§AÅܧó¬YÀx¦s®æ«á¡A«ö¤UEnterÁä©ÎTabÁä¡A³o®ÉWorksheet_SelectionChange·|¤ñWorksheet_Change¥ýIJµo¨Æ¥ó¡A
¦Ó§A¦bWorksheet_Change ¨Æ¥ó¤¤¥[¤W Application.EnableEvents = False ¬OµL®Äªº¡A¥¦¥ý±Ò°Ê¤FWorksheet_SelectionChange¨Æ¥ó
°£«DÃö³¬±¼ "«öEnterÁä«á¡A²¾°Ê¿ï¨ú½d³ò":°Ñ·Ó¤U¹Ï¡A¤£­n¤Ä¿ï³o­Ó¶µ¥Ø

©ÎªÌ¥[¤W³o2­Ó¨Æ¥ó
  1. Private Sub Worksheet_Activate()
  2. Application.MoveAfterReturn = False
  3. End Sub

  4. Private Sub Worksheet_Deactivate()
  5. Application.MoveAfterReturn = True
  6. End Sub
½Æ»s¥N½X
¤]´N¬O»¡·í§A§ïÅܤFÀx¦s®æ¤º®e«á«ö¤UEnterÁ䤣­n²¾°Ê¿ï¨úªºÀx¦s®æ¦Ó¬O¥ÎWorksheet_Change¥h²¾°Ê¥¦

TOP

¥»©«³Ì«á¥Ñ lpk187 ©ó 2017-5-30 00:18 ½s¿è

¦^´_ 1# enoch

¦p¤U¡G
  1. Dim xl_Address '³]¤@­Ó¤½¥ÎÅܼơAŪ¨ú¦ì§}¥Î

  2. Private Sub Worksheet_Change(ByVal Target As Range)
  3.     Application.EnableEvents = False '³o¸Ì¥u¬O¼È®É¶}³¬¡A¼È®É¤£·|IJµo¤U¤@¦æªº²¾°Ê(¥u¬O¼È®Éªº¡A¥¦ÁÙ¬OIJµo¡A¥u§A§A¤@¥´¶}¡A¥¦ÁÙ¬O·|IJµoªº)
  4.     Target.Offset(1).Select '°õ¦æ³o¦æ®É¨Ã¤£·|±Ò°ÊWorksheet_SelectionChange
  5.     xl_Address = Target.Address ' ¦Û³]±ø¥óÂ_ÂI¡A¥H§Q Worksheet_SelectionChange §PÂ_¥Î
  6.     Application.EnableEvents = True '·í³o¸Ì¥´¶}®É¡A¤@¼Ë·|±Ò°Ê SelectionChange ¤£¹L©O¡A¥¦²¾°Êªº¦ì¸m?¬O¥Ø«eªºÀx¦s®æ¦ì¸m¡A¤ñ¦p»¡¦bA1§ïÅܤº®e¦Ó²¾°Êªº¦ì¸mÁÙ¬OA1
  7. End Sub

  8. Private Sub Worksheet_SelectionChange(ByVal Target As Range) '©Ò¥H¦b³o¸Ìªº¤@¶}©l´N­n¥[¤J§PÂ_¤F
  9.     If xl_Address = Target.Address Then '·í¥Ø¼ÐÀx¦s®æªº¦ì§}©MWorksheet_Change¤@¼Ë®É¡A¸õ¥X¦¹¨Æ¥ó
  10.         xl_Address = Null '³]xl_Address¬°null¡A³o¼Ë·í§AÀx¦s®æ¦ì¸m§ïÅܮɤ]¤£·|¦]¦¹¦Ó¤£¦AIJ°Ê SelectionChange¨Æ¥ó
  11.         Exit Sub 'Â÷¶}¦¹¨Æ¥ó
  12.     End If
  13. Cells(1, 1).Select '©Ò¥H·íÀx¦s®æ¤º®e§ïÅܮɳo¸Ì¬O¤£·|°õ¦æªº(³o¸Ì¥u¬O°²³]ªºµ{¦¡½X¡A¤]¬O§A¦Û¤vªºµ{¦¡½X³¡¥÷¡A¤£­n§Û¶i¥h§Aªºµ{¦¡½X¤¤)
  14. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ±o²z­nÄǤH¡A²zª½­n®ð©M¡C
ªð¦^¦Cªí ¤W¤@¥DÃD