返回列表 上一主題 發帖

二個巨集程式問題

二個巨集程式問題

1.請問我的巨集程式中有很多個CommandButton (1   2    3),每個CommandButton下面都有個別巨集程式
現在我要做一個CommandButton4 執行後可以依序執行CommandButton1→CommandButton2→CommandButton3巨集程式?
(在不使用到模組的情況下)
2.如何設計巨集程式來自動啟動excel 樞紐分析表中"更新資料"的功能
以上請各位先進協助~~謝謝

抱歉~~剛剛傳錯了~~
改成如此後測試已正常~~感恩
Run "02_技師保母成效_程式.xls!Sheet1.CommandButton7_Click"

TOP

是指shee1(程式)
Workbooks("02_技師保母成效_程式.xls").Sheet1.CommandButton7_Click

TOP

回復 13# lone_tiger0303
Run "02_技師保母成效_程式.xls!Sheets(程式).CommandButton7_Click"
Sheets(程式). 改用 CodeName   vba 裡物件的名稱

TOP

oobird老師
用這樣去跑會出現"陣列索引超出範圍"

TOP

Private Sub CommandButton1_Click()
Application.Calculation = xlCalculationManual '手動計算
Workbooks.Open Filename:="C:\Documents and Settings\k1489.KT_DOMAIN\桌面\李鎮江\02_技師保母\02_技師保母成效_程式.xls"  '開檔
Run "02_技師保母成效_程式.xls!Sheets(程式).CommandButton7_Click"
ActiveWorkbook.PrecisionAsDisplayed = False
ActiveSheet.Calculate
End Sub

好像不行耶

TOP

回復 10# lone_tiger0303
如何用excel檔案B中的commandButton1 ->  Run "B!Sheet1.CommandButton1_Click"
去執行excel檔案A中的commandButton1 ->  Run "A!Sheet1.CommandButton1_Click"

TOP

注意看兩個之間不同的設定

TOP

oobird 老師
我是指已經用巨集(excel檔案B)來開啟一個excel檔案A
但要
如何用excel檔案B中的commandButton1
去執行excel檔案A中的commandButton1

TOP

不同檔案的巨集要執行還是必須把該檔案打開
或用個人巨集活頁簿或用增益集幕後開啟。

TOP

        靜思自在 : 人的心地是一畦田,土地沒有播下好種子,也長不出好的果實。 -
返回列表 上一主題