¤Á´«¤u§@ªí«áµLªk§ó·s³Q½Æ»sÀx¦s®æ¸ê®Æ
- ©«¤l
- 9
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 18
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2011-12-12
- ³Ì«áµn¿ý
- 2013-9-16
|
¤Á´«¤u§@ªí«áµLªk§ó·s³Q½Æ»sÀx¦s®æ¸ê®Æ
§Ú¦b Sheet1 ±µ¦¬ DDE ³ø»ù¸ê®Æ»P³]©wÅã¥Ü¹Ïªí¡AµM«á¼g VBA µ{¦¡¡A©T©w¨C 30 ¬í¦b Sheet2 ¬ö¿ý±q DDE ©Ò±µ¦¬ªºÅܰʸê®Æ¡C
§Úªº°ÝÃD¬O¡A·í¤Á´«¨ì Sheet2 ¤u§@ªí®É¡A¾ãÓ¹BÂà¤@¤Á¥¿±`¡F¦ý¬OY·í§Ú¤Á´«¨ì Sheet1 ®É·QÆ[¬Ý¹Ïªíªº§Y®ÉÅã¥Ü¡ASheet2 ¤ºªº¬ö¿ý´N·|°±¤î¡A°£«D¦A¤Á´«¦Ü Sheet2 ¤u§@ªí¡A¤~¤S·|©w®É¬ö¿ý¡C
§Úªº VBA µ{¦¡¦p¤U¡G
-------------------------------------------------------------
Option Explicit
Public nRow, Pos As Integer
Private Sub Workbook_Open()
On Error Resume Next
'Application.OnTime TimeValue("08:43:00"), "ThisWorkBook.SyncData"
Call SyncData
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkBook.SyncData", , False
End Sub
'*****************************************************************************
' ±N DDE §Y®É³ø»ù¸ê®Æ¨Ì®É¶¡¶¡¹j¼g¤J¦Ü³ø»ù¸ê®Æ°Ï
'*****************************************************************************
Public Sub SyncData()
On Error Resume Next
'If TimeValue(Now) > TimeValue("13:46:00") Then Exit Sub
With .Sheets("§Y®É¸ê®Æ")
nRow = .Range("A65536").End(xlUp).Row '§PÂ_³Ì«á¤@¦C¦³¸ê®Æªº¦ì¸m
Pos = nRow + 1
Cells(Pos, 1) = Time
Cells(Pos, 3) = Sheets("DDE³ø»ù").Cells(7, 3) '¥x«ü´Á¦¨¥æ»ù
End With
Application.OnTime Now + TimeValue("00:00:30"), "ThisWorkBook.SyncData" '¨C¹j©T©w³]©w®É¶¡°õ¦æ¼g¤J¦Ü§Y®É¸ê®Æªí
End Sub
-----------------------------------------------------------------------------
§Úªº VBA µ{¦¡¬O¼g¦b "ThisWorkBook" ¤º¡C
½Ð°Ý¡G
1. µ{¦¡¤ºþ¸Ì¦³°ÝÃD¡H ¦Ó¾ÉP¤Á´«¨ì¨ä¥¦¤u§@ªí«á´N°±¤î¬ö¿ý¡C
2. ¨ì©³³oµ{¦¡ (SyncData) ¬O§_¼g¦b ThisWorkBook ÁÙ¬O Module ¤º¤ñ¸û²z·Q©O¡H §Ú¤@ª½·d¤£¤ÓÀ´ ThisWorkBook »P Module ªº®t§O¡C |
|
|
|
|
|
|
- ©«¤l
- 9
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 18
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2011-12-12
- ³Ì«áµn¿ý
- 2013-9-16
|
¦Û°Ý¦Ûµª¤@¤U¡C
¥Ø«e§Ú¬O¨Ï¥Î Sheet2.Activate ¨Ó¸Ñ¨M¡C¦ý³o¼Ë¦³¨Ç°ÝÃD¡A¦pªG§A·QÀH®ÉÆ[¬Ý¹Ïªí®É (Sheet1)¡AVBA µ{¦¡·í¹J¨ì Sheet2.Activate ´N·|¤Á´«¨ì Sheet2 ¤u§@ªí¡C
©Ò¥H¥u¦n·í¤Á¦^ Sheet2 ³B²z§¹Àx¦s®æªº½Æ»s®É¡A¦A¨Ì¾Úì¨Ó©Ò¦bªº¤u§@ªí¡A¨ú±o¦WºÙ«á¡A¦A¤U«ü¥O¤Á¦^¥h¡C³o¼Ëªº«á¿ò¯g¬Oµe±±`·|°{°Ê¤@¤U (¦]¬°¤Á¨ì Sheet2 ¤S¤Á¦^ Sheet1)¡C
³B²zªºÅÞ¿è¬O³o¼Ë¡G
name = ThisWorkbook.ActiveSheet.Name
Sheet2.Select
......
......
......
ThisWorkbook.Sheets(name).Activate
¤£ª¾¹Dª©¤W¦³¸gÅ窺¤j¤j̬O§_¦³§ó¨Îªº¸Ñ¨M¤è®×¡H |
|
|
|
|
|
|
- ©«¤l
- 9
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 18
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2011-12-12
- ³Ì«áµn¿ý
- 2013-9-16
|
¦^´_ gnimnek168
.Cells(Pos, 1) = Time
.Cells(Pos, 3) = Sheets("DDE³ø»ù").Cells(7, 3)
¬O¼g¤J§Y®É¸ê®Æ¤u§@ªí¶Ü?
with°Ï¬q¤ºn¥[¤J.
¤£¦n·N«ä¡A¤£¤F¸Ñ±zªº»¡©ú¡H
¤Wz¨âÓ Cell Àx¦s®æ¬O¦b "§Y®É¸ê®Æ" ¤u§@ªí (sheet2) ¨S¿ù¡C |
|
|
|
|
|
|
- ©«¤l
- 9
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 18
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2011-12-12
- ³Ì«áµn¿ý
- 2013-9-16
|
¥»©«³Ì«á¥Ñ gnimnek168 ©ó 2011-12-15 23:55 ½s¿è
¦^´_ gnimnek168
´N¦]¬°§An¼g¤Jªº¦ì¸m¦b§Y®É¸ê®Æ¤u§@ªí
©Ò¥H¥²¶·«ü¦W¤u§@ªí¡A¦b¤Á´«¤u§@ªí®É¤~ ...
Hsieh µoªí©ó 2011-12-15 17:28
½Ð°Ý³oÓ¡GWith .Sheets("§Y®É¸ê®Æ")¡A¤£¬O¤w¸g¦³«ü©w¤u§@ªí¦WºÙ¤F¶Ü¡H
==============================================
°Ú°Ú¡A§ÚÁA¸Ñ¤j¤jªº·N«ä¤F¡Aì¨Ó´N¬O CELL() «e±n¥[¤W .CELL¡C
«¢¡A»°ºò¨Ó¸Õ¸Õ¬Ý¡A·PÁ·PÁ¡C ^^ |
|
|
|
|
|
|