Beatrice
Board Regular
- Joined
- Sep 17, 2019
- Messages
- 85
- Office Version
- 2019
- Platform
- Windows
I need some help here as still learning Excel Macros
I have few sets of code within an excel file.
1) clear "results" data if "input" criteria has any change
2) Export "results" as a separated file in values only - button
3) Import "Database"- button
So far, I tested them separately, all are working.
However, I would like to run the "Import Database" without a button
Here is my trial:
--------------------------------------------
Sub Autpen()
MsgBox "Please allow a few second for importing..."
' Open Source and Destination files
ChDir "S:\Project"
Workbooks.Open Filename:="S:\Project\Database.xlsx"
' Copy Dedicated Part
Workbooks("Database.xlsx").Sheets("Database").Range("A1:K50").Copy
Workbooks("Export.xlsm").Sheets("Database").Range("A1").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Windows("Database.xlsx").Activate
ActiveWindow.Close
End Sub
-------------------------------------
but it is not running automatically as expect, can someone tell me what did I do wrong?
Thanks in advance for your help.
I have few sets of code within an excel file.
1) clear "results" data if "input" criteria has any change
2) Export "results" as a separated file in values only - button
3) Import "Database"- button
So far, I tested them separately, all are working.
However, I would like to run the "Import Database" without a button
Here is my trial:
--------------------------------------------
Sub Autpen()
MsgBox "Please allow a few second for importing..."
' Open Source and Destination files
ChDir "S:\Project"
Workbooks.Open Filename:="S:\Project\Database.xlsx"
' Copy Dedicated Part
Workbooks("Database.xlsx").Sheets("Database").Range("A1:K50").Copy
Workbooks("Export.xlsm").Sheets("Database").Range("A1").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Windows("Database.xlsx").Activate
ActiveWindow.Close
End Sub
-------------------------------------
but it is not running automatically as expect, can someone tell me what did I do wrong?
Thanks in advance for your help.