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

excel VBA calculate ªººÃ°Ý

excel VBA calculate ªººÃ°Ý

Àx¦s®æA1 ·|±q¥~³¡±µ¦¬¸ê®Æ (DDE±µ¦¬¶}½L»ù)
¨Ò¦p ¥x¿n¹q¶}½L»ù
§Ú³]©w¤@­Ó¥Ø¼Ð (100¤¸)
¦pªG·í¤Ñ¶}½L>=100
´N·|°õ¦æ°e³æ

§ÚGOOGLE¤F¤@¤U
ºô¸ô¤W³£¬O±Ð¨Ï¥Î calculate ©Mchange³o¨â­Ó«ü¥O
¦]¬°±µ¦¬¥~³¡¸ê®Æ
©Ò¥H¥u¯à¨Ï¥Îcalculate

¦ý§Ú¸Õ¤F¤@¤U
µo²{¨â­Ó°ÝÃD
1. ´N¬O§Ú¥D°Ê§ïA1(§ï¬°101)ªº­È, ¨Ã¤£·|¥D°Ê°e³æ, ¦Ó¬O­n±qVB¸Ì­±«ö°õ¦æ¤~·|°e¥X³æ¤l.

2. ¤@¥¹«ö¤F°õ¦æ, ´N·|¤@ª½°e³æ°e­Ó¤£°±, ¦³¨S¦³¿ìªk³]©w¦¨A1ÅÜ°Ê1¦¸, °e³æ1¦¸©O??
excel VBA ¦nÃø³á...

¦^´_ 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

¦^´_ 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

¦^´_ 3# shy
½Ð§A¤W¶ÇÀɮפ~²M·¡°ÝÃDÄpµ²
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ shy ©ó 2013-5-9 11:19 ½s¿è

¦^´_ 4# GBKEE

§Ú¨S¦³¿ìªk¤W¶ÇÀÉ®×
¦n©Ç³á

§Ú¶K§Ú¼gªº

        A                 B                   C                  D
1   ¥N½X           °Ó«~            ¦¨¥æ            ¬Q¦¬
2   2330          ¥x¿n¹q           115.5           114.5
3                       
4                                                                             1

§Ú¥´¦bthis workbook

Private Declare Function PlaceOrderVB Lib "TC_Excel_Addin.xll" (ByVal OrderInfo As String) As String
Option Explicit
------------------------------------------------------------------------------------
Private Sub Worksheet_calculate()

Dim tmpResult As String
Dim OrderInfo_1 As String
tmpResult = ""

OrderInfo_1 = "" ' ¸Ì­±¬O­Ó¸ê, ¤U³æªº³]©w
tmpResult = PlaceOrderVB(OrderInfo_1)
MsgBox tmpResult

Application.EnableEvents = False

If Range("D4") >= 0 Then
PlaceOrderVB (OrderInfo_1)

End If


End Sub
excel VBA ¦nÃø³á...

TOP

¦^´_ 5# shy
2# µ{¦¡¤¤§A­n«ì´_£«
09.    Application.EnableEvents = True
17.    Application.EnableEvents = True

·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 6# GBKEE

§Úª¾¹D­n³o¼Ë¤W¶Çªü
¦ý¬O«ö¤F¤W¶Ç«á
·|¥X²{
¹ï¤£°_¡A¤£¤ä«ù¤W¶Ç¦¹ÃþÂX®i¦Wªºªþ¥ó¡C
³o¼Ëªº¦r...
excel VBA ¦nÃø³á...

TOP

¦^´_ 6# GBKEE

Åܦ¨³o¼Ë??
Private Declare Function PlaceOrderVB Lib "TC_Excel_Addin.xll" (ByVal OrderInfo As String) As String
Option Explicit
------------------------------------------------------------------------------------
Private Sub Worksheet_calculate()

Dim tmpResult As String
Dim OrderInfo_1 As String
tmpResult = ""

OrderInfo_1 = "" ' ¸Ì­±¬O­Ó¸ê, ¤U³æªº³]©w
tmpResult = PlaceOrderVB(OrderInfo_1)
MsgBox tmpResult

Application.EnableEvents = False

If Range("D4") >= 0 Then
PlaceOrderVB (OrderInfo_1)

End If

Application.EnableEvents =ture

End Sub
excel VBA ¦nÃø³á...

TOP

¦^´_ 8# shy
¤£¬O ture ¬O TRUE
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ shy ©ó 2013-5-9 12:53 ½s¿è

¦^´_ 9# GBKEE

sorry
¬Otrue¤~¹ï

©Ò¥H¬O³o¼Ë??

Private Declare Function PlaceOrderVB Lib "TC_Excel_Addin.xll" (ByVal OrderInfo As String) As String
Option Explicit
------------------------------------------------------------------------------------
Private Sub Worksheet_calculate()

Dim tmpResult As String
Dim OrderInfo_1 As String
tmpResult = ""

OrderInfo_1 = "" ' ¸Ì­±¬O­Ó¸ê, ¤U³æªº³]©w
tmpResult = PlaceOrderVB(OrderInfo_1)
MsgBox tmpResult

Application.EnableEvents = False

If Range("D4") >= 0 Then
PlaceOrderVB (OrderInfo_1)

End If

Application.EnableEvents =true

End Sub


ÁÙ¬O¤£·|¦Û¤v°Ê....
excel VBA ¦nÃø³á...

TOP

        ÀR«ä¦Û¦b : ­×¦æ­nô½t­×¤ß¡AÂǨƽm¤ß¡AÀH³B¾i¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD