1
我想用下面的問題協助懇請:application.run(宏,ARG1,Arg2)將
我試圖運行運行多個宏宏,但它是基於2串如下:
Sub ExportDatatoCountriesSheets()
Dim shtnme As String
Dim country As String
' United States
shtnme = "US"
country = "United States"
' ClearLatestData
Application.Run "ClearLatestData"
' FilterExportDataByCountry
Application.Run "FilterExportDataByCountry"
' Japan
shtnme = "JP"
country = "Japan"
' ClearLatestData
Application.Run "ClearLatestData"
' FilterExportDataByCountry
Application.Run "FilterExportDataByCountry"
End Sub
'==============================================================
Sub ClearLatestData()
Dim shtnme As String
Dim country As String
Sheets(CStr(shtnme)).Activate
Columns("A:Z").Select
Selection.Clear
End Sub
'==============================================================
Sub FilterExportDataByCountry
Sheets("WEEKLY DATA").Select
ActiveSheet.Range("$A$1:$G$240").AutoFilter Field:=3, Criteria1:=CStr(country)
Columns("A:G").Select
Selection.Copy
Sheets(CStr(shtnme)).Activate
Range("A1").Select
ActiveSheet.Paste
但是,我不斷收到錯誤。我基本上想要設置ExportDatatoCountriesSheets
宏來重複,而我輸入的代碼,並運行其他應用程序。運行
我搜索和最接近的解決方案是運行宏的參數,但當我定義參數的宏無法正常運行併發生錯誤。
Application.Run (ClearLatestData, shtnme = "US", country = "United States")
如果可能請告知。
工作像一個魅力先生。感謝你的協助!非常感激。 –
@ShahA歡迎您通過點擊答案旁邊的greay複選標記(標記爲綠色),標記爲「答案」 –