Hello,
I am looking for a VBA code that reads the active workbook name, in order to use it later as reference in order to activate/open the same workbook in question.
Background: The VBA code is activated in "workbook1.xlsm" via a script button and exports data from SAP into a temp. Excel spreadsheet, this data is then copied to "Sheet1" in "workbook1.xlsm".
Issue: When changing the workbook name of "workbook1.xlsm", for example to "workbook2.xlsm", I have to update the workbook reference name in VBA code as well in order to prevent an error.
Questions:
I am looking for a VBA code that reads the active workbook name, in order to use it later as reference in order to activate/open the same workbook in question.
Background: The VBA code is activated in "workbook1.xlsm" via a script button and exports data from SAP into a temp. Excel spreadsheet, this data is then copied to "Sheet1" in "workbook1.xlsm".
Issue: When changing the workbook name of "workbook1.xlsm", for example to "workbook2.xlsm", I have to update the workbook reference name in VBA code as well in order to prevent an error.
Questions:
- Can you help me out with a code that is reading the active workbook name, in order to use it later when the data is copied from the temp. Excel workbook?
- Can you help me out with a code that is (first of all) checking if "Sheet1" is present in the workbook?
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("workbook1.xlsm").Activate
Sheets("Sheet1").Select
Range("A2").Select
ActiveSheet.Paste