Hi all!
I have problems with reopening a workbook via vba.
I need to run several macros on the same excel workbook.
Each macro deletes cells in the original workbook. Just to clarify, the original workbook contains data of 8 different users and I use the macros to create 8 workbooks, one for each user. In each workbook there must be data related to one user only. So, macro 1 keeps data of User1 (deleting data of all other users) and saves workbook1, macro2 keeps data of user 2 and saves workbook2 and so on.
Since each macro makes changes on the genuine workbook, at the end of each macro I do a SaveAs and try to reopen the original workbook to run the next macro which will make other changes. I have tried to put the vba code on a new workbook so that I can open the workbook (to be changed) and run the macros on it:
Sub Test()
Open the workbook
Run Macro1 (which makes changes, saves the updated workbook with 'Save as')
Open again the original workbook
Run Macro2
End Sub()
I used this code:
Sub test()
Workbooks.Open Filename:="C:...Report.xlsm"
Application.Run ("Report.xlsm!Delete_1")
Workbooks.Open Filename:="C:...Report.xlsm"
Application.Run ("Report.xlsm!Delete_2")
End Sub
The problem is that the first macro is run OK but then the workbook is not reopened. It seems like the vba stops running. How can I reopen the original workbook?
Can anyone help me? Many thanks in advance!
Vale
I have problems with reopening a workbook via vba.
I need to run several macros on the same excel workbook.
Each macro deletes cells in the original workbook. Just to clarify, the original workbook contains data of 8 different users and I use the macros to create 8 workbooks, one for each user. In each workbook there must be data related to one user only. So, macro 1 keeps data of User1 (deleting data of all other users) and saves workbook1, macro2 keeps data of user 2 and saves workbook2 and so on.
Since each macro makes changes on the genuine workbook, at the end of each macro I do a SaveAs and try to reopen the original workbook to run the next macro which will make other changes. I have tried to put the vba code on a new workbook so that I can open the workbook (to be changed) and run the macros on it:
Sub Test()
Open the workbook
Run Macro1 (which makes changes, saves the updated workbook with 'Save as')
Open again the original workbook
Run Macro2
End Sub()
I used this code:
Sub test()
Workbooks.Open Filename:="C:...Report.xlsm"
Application.Run ("Report.xlsm!Delete_1")
Workbooks.Open Filename:="C:...Report.xlsm"
Application.Run ("Report.xlsm!Delete_2")
End Sub
The problem is that the first macro is run OK but then the workbook is not reopened. It seems like the vba stops running. How can I reopen the original workbook?
Can anyone help me? Many thanks in advance!
Vale