excel表外部連結的自動更新

來源:互聯網
上載者:User

有兩個excel檔案,一個叫source.xls另一個叫use.xls。現在use.xls中有指向source.xls的連結,比如:

='G:/share/作業/[source.xls]Sheet1'!$A$1  ('G:/share/作業/ 為source的路徑)

當共用use.xls檔案時,別人開啟了use.xls。但是想令source.xls被引用的資料如果有改變也能及時更新到別人開啟的use.xls上。

當然,使用use.xls的人可以手動從“編輯”-“連結”-“更新值”得到最新的資料。下面給出的是一個定時更新的方法:use.xls每隔15秒更新資料來源連結。

Sub update()
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
Application.OnTime Now + TimeValue("00:00:15"), "update"
End Sub

一個遞迴過程。

為了讓use.xls一啟動就可以開啟程式,我們添加了一個過程:

Sub workbook_open()
Application.OnTime Now + TimeValue("00:00:15"), "update"
End Sub

之前為了達到此目的,將ontime函數放入一個無限迴圈中,導致程式總是忙...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.