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

excel VBA calculate ªººÃ°Ý

¦^´_ 2# GBKEE
¬Q¤Ñ¸Õ¤F´X¦¸
µo²{ÁÙ¬O¤£¦æ
§Ú«á¨Óµo²{¬O§Ú°Ýªº¤£¦n
§Ú­«·s°Ý§Úªº°ÝÃD¦n¤F


Àx¦s®æA1 ·|±q¥~³¡±µ¦¬¸ê®Æ (DDE±µ¦¬¶}½L»ù)
¨Ò¦p ¥x¿n¹q¦¨¥æ»ù
°²³]Àx¦s®æB1¬O¬Q¤é¦¬½L»ù(DDE±µ¦¬¦¬½L»ù)
¦pªG·í¤Ñ¦¨¥æ»ù¤j©ó¦¬½L»ù
´N·|°õ¦æ°e³æ

¦ý¬O§Ú¼g¥X¨Óªºµ{¦¡
³£­n¥Î¤H¤u¥h«ö°õ¦æ
¨S¦³¿ìªk¦Û°Ê
§ÚGOOGLE¤F¤@¤U
ºô¸ô¤W³£¬O±Ð¨Ï¥Î calculate ©Mchange³o¨â­Ó«ü¥O
¦]¬°±µ¦¬¥~³¡¸ê®Æ
©Ò¥H¥u¯à¨Ï¥Îcalculate

¦ý§Ú¸Õ¤F¤@¤U
µo²{¨â­Ó°ÝÃD
1. §Ú¬O§Q¥ÎC1=A1-B1
     if C1 >0 Then °õ¦æ
     µM«á¦^¨ìsheet1, µo²{C1>0ªº®É­Ô¤£·|¦Û¤v°Ê
     ¤@©w­n¦^¨ìVB¸Ì­±«ö°õ¦æ, ¦ý«ö¤F°õ¦æ, ´N·|¤@ª½°e³æ°e­Ó¤£°±, ¦³¨S¦³¿ìªk³]©w¦¨C1ÅÜ°Ê1¦¸, ¥u°õ¦æ1¦¸©O??

2.  §Ú¥Î¤F
     Application.EnableEvents = False
    ÁöµM¤£·|¤@ª½°õ¦æ°Ê§@
    ¦ý¬O¦^¨ìsheet1, µo²{C1>0 ªº®É­ÔÁÙ¬O¤£·|¦Û¤v°Ê§@
    Ãø¹D­n¥Îchange³o­Ó«ü¥O¶Ü? (¦ýC1¬O¤½¦¡ªü...)
    ¦ý¬O¥Î¤Fchange
    ·|¥X²{¤@­Óª¬ªp
    ´N¬O¨C¦¸«ö°õ¦æ
    ´N·|¥X²{¥¨¶°ªº®Ø®Ø¥X¨Ó....
excel VBA ¦nÃø³á...

TOP

¦^´_ 1# shy
  1. Option Explicit
  2. Private Sub Worksheet_Calculate()  '¤u§@ªí­«ºâ¨Æ¥ó
  3.     '¥D°Ê§ïA1(§ï¬°101)ªº­È¤§«á:  A1¨S¦³=¤½¦¡ ¤£·|±Ò°Ê [¤u§@ªí­«ºâ¨Æ¥ó]
  4.     '¦pA1=¤½¦¡   ¤½¦¡ªº­È¦³ÅÜ°Ê ·|±Ò°Ê [¤u§@ªí­«ºâ¨Æ¥ó]
  5.     Application.EnableEvents = False
  6.     'µ{¦¡½X.(­×§ï¨ì¤u§@ªí¤½¦¡°Ñ·Ó¨ìªºÀx¦s®æ)......  '·í¨S¦³ Application.EnableEvents = False'·|¤@ª½°e³æ°e­Ó¤£°±
  7.     'µ{¦¡½X.(­×§ï¨ì¤u§@ªí¤½¦¡°Ñ·Ó¨ìªºÀx¦s®æ)......
  8.     'µ{¦¡½X.......
  9.     Application.EnableEvents = True
  10. End Sub
  11. Private Sub Worksheet_Change(ByVal Target As Range) '¤u§@ªí¤º®e¦³Åܰʨƥó
  12.     '¥D°Ê§ïA1(§ï¬°101)ªº­È¤§«á:  A1¨S¦³=¤½¦¡ ·|±Ò°Ê [¤u§@ªí¤º®e¦³Åܰʨƥó]
  13.     Application.EnableEvents = False
  14.     'µ{¦¡½X..(¦³­×§ï¨ì¤u§@ªíªº¤º®e)....  '·í¨S¦³ Application.EnableEvents = False'·|¤@ª½°e³æ°e­Ó¤£°±
  15.     'µ{¦¡½X..(¦³­×§ï¨ì¤u§@ªíªº¤º®e)....
  16.     'µ{¦¡½X..(¦³­×§ï¨ì¤u§@ªíªº¤º®e)....
  17.     Application.EnableEvents = True
  18. End Sub
½Æ»s¥N½X
  1. EnableEvents ÄÝ©Ê
  2. ½Ð°Ñ¾\®M¥Î¦Ü½d¨Ò¯S©w¦pªG«ü©wª«¥ó¯àIJµo¨Æ¥ó¡A«h¥»Äݩʬ° True¡CŪ/¼g Boolean¡C
  3. ¥»½d¨Ò·|¦bÀx¦sÀɮפ§«e°±¥Î¨Æ¥ó¡A±q¦Ó¨Ï BeforeSave ¨Æ¥ó¤£·|µo¥Í¡C
  4. Application.EnableEvents = False
  5. ActiveWorkbook.Save
  6. Application.EnableEvents = True
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¦Y­W¤F­W¡B­WºÉ¤Ü¨Ó¡A¨ÉºÖ¤FºÖ¡BºÖºÉ´d¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD