ªð¦^¦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Ãø³á...

¡ÕDDE¤u§@ªí¸ê®Æ¨Ò¡Ö
20130516-01.JPG

¡Õ¤u§@ªí¨Æ¥ó°Ï¡Dµ{¦¡½X¡Ö
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
If Date Mod 7 - 1 > 5 Then Exit Sub ¡@¡@'¤µ¤Ñ¬°¡e©P¤»¡D©P¤é¡f«D¥æ©ö¤é¡D¸õ¥X
If Time < TimeValue("08:00:00") Then Exit Sub¡@ ¡@'¥¼¨ì¶}½L¡D¸õ¥X
If Time > TimeValue("13:45:00") Then Exit Sub¡@¡@ '¤w¹L¦¬½L¡D¸õ¥X
If [D5] = "¤w°e³æ" And [D6] = Date Then Exit Sub ¡@¡@'¤µ¤Ñ¤w¦³°e³æ°O¿ý¡D¸õ¥X
If IsError([D4]) Then Exit Sub ¡@¡@ 'DDE¥¼¥¿½T³sµ²¡A©Î¤½¦¡¦³»~¡D¸õ¥X
If Val([D4]) < 0 Then Exit Sub ¡@¡@'¥¼¹F¥Ø¼Ð»ù¡D¸õ¥X
On Error GoTo 901 ¡@¡@¡@'µ{¦¡°õ¦æ¿ù»~®É¡A±j¨î¸õ¦Ü901¦æ¡A¥H¦^´_¨Æ¥óIJµo¡A¨Ã¸õ¥X
'-------------------------------------------
Application.EnableEvents = False
OrderInfo_1 = "" ' ¸Ì­±¬O­Ó¸ê, ¤U³æªº³]©w
tmpResult = PlaceOrderVB(OrderInfo_1)
PlaceOrderVB (OrderInfo_1)
[D5] = "¤w°e³æ"¡@'°e³æ°T®§
[D6] = Date¡@¡@'°e³æ¤é´Á
[D7] = Time¡@¡@'°e³æ®É¶¡
901: Application.EnableEvents = True
End Sub

¡Õ³Æµù¡Ö
¥H¤u§@ªí¨Æ¥ó¶i¦æDDE°ÊºAºÊµø¡A¨Ã¤£¤Ó¦n´x±±¡A¤§«e¦³¼g¹L´X­Ó½d¨Ò¡A¬O¥H¡e¨C¬í¡f»¼°j¥Dµ{¦¡ºÊµø¤Î°O¿ý¼Æ¾Ú¡A
¥i¦Ü±Í³¡¸¨®æ¡A©Îºô­¶·j´MÃöÁä¦r¡e­ã´£³¡ªL ª÷¤d¨½ DDE¡f°Ñ¦Ò¬ÛÃö¤U¸üÀÉ¡]µ{¦¡½X¤½¶}¡A¥B¦³µù¸Ñ¡^¡A
­Ó¤H¨ÃµL¾Þ§@ªÑ²¼¤Î¨ä¥¦ª÷¿Ä°Ó«~¡A¤]±q¥¼¨Ï¥Î¹LDDE¡A¶È¾Ì´¢ºN¼gµ{¦¡¡A©Ò¥H½Ð¦Û¦æ®M¥Î¡AµLªk°µ¨p¤HªºªA°È¡C
º¸«á­Y¦³®É¶¡¡D©Î³\¤]¦b³o½×¾Â«Ø­Ó¡e¦Û°Ê°O¿ýDDE¡fÃD¤À¨É¡I

¥H¤W¯Â¦]ª©¥D¤@¥y¡eVBA¦nÃø¡f¡AÀ³½t¦Óµo¡I¡@¯¬¡@¾Þ§@¶¶§Q

TOP

¦^´_ 29# GBKEE


¤j­ô
§Úı±oÀ³¸Ó¬ODDEªº°ÝÃD, À³¸Ó¤£¬Oµ{¦¡ªº°ÝÃD
¦]¬°§Y¨Ï¬O²{¦b§Ú¥´¶}ÀÉ®×
©Ò¦³¼Æ¦r³£¨S¦³§ïÅܪº±¡ªp¤§¤U(¤½¦¡·íµM¤]¨S¦³ÅÜ)
Ãö±¼ÀÉ®×
EXCEL³£·|¥X²{==> Àɮפw³Q­×§ï¹L, §A¬O§_­nÀx¦sÀɮתºmsgbox

©Ò¥H§Ú²q§Y¨Ï³£¨S¦³Åܪº±¡ªp¤§¤U
DDEÁÙ¬O¦³°Ê§@
§Ú²q¬O¤@¥´¶}ÀÉ®×
EXCEL´N·|¥h§ìDDEªº¸ê®Æ
©Ò¥H§Y¨Ï¼Æ¦r¨S¦³ÅÜ
¦ý¬O¹ïEXCEL¨Ó»¡
«o¬O­«·s§ìªº
excel VBA ¦nÃø³á...

TOP

¦^´_ 29# GBKEE

¤u§@ªí¤W¥u¦³3­ÓÀx¦s®æ¦³¼Æ¦r
¤µ¤é¶}½L»ù    ¬Q¤é¦¬½L»ù
ÁÙ¦³¤@­ÓÀx¦s®æ¬° ¤µ¤é¶}½L»ù-¬Q¤é¦¬½L»ù

©Ò¥H¤@¶}½L¤§«á
¼Æ¦rÁÙ¦³¤½¦¡´N³£¤£·|ÅܤF....
excel VBA ¦nÃø³á...

TOP

¦^´_ 28# shy
°ò¥»·§©À:¤u§@ªí¤Wªº¤½¦¡¶Ç¦^ªº¼Æ­ÈÅܰʤ@¦¸,°õ¦æSub Worksheet_Calculate() ¤@¦¸.
§A»¡¤u§@ªí¤WªºDDE¤½¦¡¤£·|¦³ÅÜ°Ê: ¬O¤½¦¡¨SÅÜ°Ê,¥B¤½¦¡¶Ç¦^ªº¼Æ­È¤]³£¤£ÅܶÜ? (¨ºªÑ¥«¦bÀç·~®É¶¡¤¤¦³¦b¥æ©ö¶Ü?)
§A»¡¤u§@ªí¤W¨C­ÓÀx¦s®æ³£¥u¦³¹ïÀ³¤@­ÓDDE¤½¦¡? ¨º³o¤u§@ªí¤W¤£¬O¦³³\¦hÀx¦s®æ¦³¤½¦¡¶Ü?(¤£¥u¤@­Ó¤½¦¡¹ï¶Ü)

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

TOP

¦^´_ 27# GBKEE

Q ¦ý¬OEXCELÁÙ¬O¤@ª½¦b°õ¦æ              ->ªÑ¥«Àç·~¤¤ : ¤u§@ªí¤WªºDEE¤½¦¡·|¦³Åܰʹï¶Ü?

¤u§@ªí¤WªºDDE¤½¦¡¤£·|¦³ÅÜ°Ê, ¦ý¬O¥i¥H½T©w¬OEXCEL«o¬O«ùÄò°õ¦æ.

Q ¦ý¤§«á²z½×¤WÀ³¸Ó¤£·|¦A°õ¦æ°e³æ¤F      ->¤u§@ªí¤WªºDEE¤½¦¡¦³¤@­Ó¥H¤W¹ï¶Ü?

¤u§@ªí¤W¨C­ÓÀx¦s®æ³£¥u¦³¹ïÀ³¤@­ÓDDE¤½¦¡

Q ¶¡¹j20¬í·|¬OEXCELªº°ÝÃD¶Ü?              ->ªÑ¥«Àç·~¤¤,·|¨C¬í¨C¤À³£¦³¥æ©ö¶Ü?

´Á³fªº¸Ü, ¨C¬í³£·|¦³¥æ©ö...
excel VBA ¦nÃø³á...

TOP

¦^´_ 26# shy
°ò¥»·§©À:¤u§@ªí¤WªºDEE¤½¦¡Åܰʤ@¦¸,°õ¦æSub Worksheet_Calculate() ¤@¦¸.

Q ¦ý¬OEXCELÁÙ¬O¤@ª½¦b°õ¦æ              ->ªÑ¥«Àç·~¤¤ : ¤u§@ªí¤WªºDEE¤½¦¡·|¦³Åܰʹï¶Ü?

Q ¦ý¤§«á²z½×¤WÀ³¸Ó¤£·|¦A°õ¦æ°e³æ¤F      ->¤u§@ªí¤WªºDEE¤½¦¡¦³¤@­Ó¥H¤W¹ï¶Ü?

Q ¶¡¹j20¬í·|¬OEXCELªº°ÝÃD¶Ü?              ->ªÑ¥«Àç·~¤¤,·|¨C¬í¨C¤À³£¦³¥æ©ö¶Ü?
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 25# shy

¥i¥H¦A½Ð±Ð¨â­Ó°ÝÃD¶Ü
´N¬O¥u·Q¤@¶}½L¥u¥æ©ö¤@¦¸
¤§«á¤£ºÞ¤£ºÞ²Å¤£²Å¦X±ø¥ó
³£¤£¦b°õ¦æ¦Û°Ê¤U³æ

­ì¦]¬O³o¼Ëªº
§Ú¦b´ú¸ÕDDE°e³æªº³t«×®É
µo²{¤@¥ó¨Æ±¡
¦pªGÀx¦s®æ¤À§O¬O==> ¤µ¤é¶}½L»ù©M¬Q¤é¦¬½L»ù
·Ó¹D²z·í¶}½L¶}¤§«á´N·|¤£°Ê¤F
¦ý¬OEXCELÁÙ¬O¤@ª½¦b°õ¦æ
¨Ò¦p
¤µ¤é¶}½L100, ¬Q¤é¦¬½L99 ==> ¤µ¶}-¬Q¦¬>=0==>²Å¦X±ø¥ó==>°õ¦æ°e³æ
¦ý¤§«á²z½×¤WÀ³¸Ó¤£·|¦A°õ¦æ°e³æ¤F
¦]¬°³o¨â­ÓÀx¦s®æªº­È¤w¸g¤£·|¦A°Ê¤F
¦ý¹ê»Úª¬ªp«o¬O¤@ª½°e³æ
§Ú²q³o¬ODDEªº°ÝÃD
©Ò¥H¤~·Q°®¯Ü¥u°õ¦æ¤@¶}½Lªº¨º¤@¦¸
¤§«á¤£ºÞ²Å¦X¤£²Å¦X³£¤£¦A°Ê§@

²Ä¤G­Ó°ÝÃD¬O
§Úµo²{°e³æªº®É¶¡«Ü³W«ß
³£¬O¶¡¹j20¬í
·Ó²z»¡
DDE­Y¬O¨C¬í³£·|¸õ°Êªº¸Ü
¤£¬OÀ³¸Ó¥u¶¡¹j1¬í¶Ü
¶¡¹j20¬í·|¬OEXCELªº°ÝÃD¶Ü
­Y¬O§Ú·Q§ï¦¨¶¡¹j1¬íªº¸Ü
¬O¤£¬O¥i¥H¦bEXCEL¤W­±§ï©O??
excel VBA ¦nÃø³á...

TOP

¦^´_ 24# Hsieh

GBKEE & Hsieh ¤j­ô
¥Ø«e°£¤F¤@¶}±ÒÀÉ®×·|°e³æ¨â¦¸¥~
(²Å¦X±ø¥ó·|¦Û°Ê°e³æ¨â¦¸, ¤£²Å¦X±ø¥ó´N¨S¦³°Ê§@...)

¨ä¥L°ò¥»¤W³£¨S¦³°ÝÃD¤F
µ{¦¡ªº¹B§@
DDE³ø»ù¸õ°Ê==>²Å¦X±ø¥ó==> ¦Û°Ê°e³æ
                                    ¤£²Å¦X±ø¥ó==> ´N¨S¦³°Ê§@

±µ¤U¨Ó¤p©f¶}©l¥H³o­Ó¬°°ò¦
¶}©l§ó¶i¤@¨Bªº¼g§@....
«D±`·PÁ§A­Ì..
excel VBA ¦nÃø³á...

TOP

¦^´_ 20# shy
¥H¤Wµ{¦¡½X¥HÅÞ¿è¨Ó¬Ý¡A¶}±ÒÀÉ®×·|°õ¦æ­«ºâ¨S¿ù¡A·|IJµoWorksheet_Calculateµ{§Ç
¦bµ{§Ç¤º§PÂ_D4¬O§_²Å¦X±ø¥ó¦Ó§PÂ_¬O§_°õ¦æ°e³æ°Ê§@
±µ¤U¨Ó·íDDE¦¬¨ì§ó·s«á³£·|IJµoWorksheet_Calculate
¦ý¬O¡A­YD4µ²ªG¤£²Å¦X±ø¥ó¤]¤£¸Ó¦³°e³æ°Ê§@
¦Ó¥B¨C¦¸°e³æ«á³£À³¸Ó·|¥X²{¹ï¸Ü¤è¶ô¤~¹ï
¹ê¦b¬Ý¤£¥X­þ­ÓÀô¸`¥X¿ù?
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¦³¤ß´N¦³ºÖ¡A¦³Ä@´N¦³¤O¡A¦Û³yºÖ¥Ð¡A¦Û±oºÖ½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD