Hi all.
I would like to be able to use an excel workbook with vba as a "backup" that I will run each month to collect data from three other closed workbooks. These workbooks are used everyday and when one became corrupt my employer panicked. This simple system would save me some work when my employer comes panicking asking if I can retrieve the lost data (I did!).
I've written the vba to run and open each workbook from a specific location on a network drive and then copy a worksheet in to the "Backup workbook" and this all runs fine. The issue is that each of the worksheets in the workbooks are named "Data" and I end up with "Data", "Data(2)" and "Data(3)" in the backup workbook. The worksheets cant be renamed in the original workbooks due to coding someone has written.
Could these worksheets be renamed via vba when excel imports them?
I'd like the sheet "Data" to become "Turnaround Audit"
"Data (2)" to become "Airbridge Inspection Audit"
"Data (3)" to become "Airbridge Operation Audit"
My coding is.....
Thank you all
I would like to be able to use an excel workbook with vba as a "backup" that I will run each month to collect data from three other closed workbooks. These workbooks are used everyday and when one became corrupt my employer panicked. This simple system would save me some work when my employer comes panicking asking if I can retrieve the lost data (I did!).
I've written the vba to run and open each workbook from a specific location on a network drive and then copy a worksheet in to the "Backup workbook" and this all runs fine. The issue is that each of the worksheets in the workbooks are named "Data" and I end up with "Data", "Data(2)" and "Data(3)" in the backup workbook. The worksheets cant be renamed in the original workbooks due to coding someone has written.
Could these worksheets be renamed via vba when excel imports them?
I'd like the sheet "Data" to become "Turnaround Audit"
"Data (2)" to become "Airbridge Inspection Audit"
"Data (3)" to become "Airbridge Operation Audit"
My coding is.....
VBA Code:
Sub CopySheetFromClosedWB()
Application.ScreenUpdating = False
'Imports as "Data" - would like it to be renamed to "Turnaround Audit"
Set closedbBook = Workbooks.Open("\\gatwick\Group9\Airfield Operations\2023 Airfield Inspection and Data\Aircraft Turnaround Audits\Aircraft Turnaround Audit 2023.xlsm")
closedbBook.Sheets("Data").Copy After:=ThisWorkbook.Sheets(1)
closedbBook.Close SaveChanges:=False
'Imports as "Data(2)" - would like it to be renamed to "Airbridge Inspection Audit"
Set closedbBook = Workbooks.Open("\\gatwick\Group9\Airfield Operations\2023 Airfield Inspection and Data\Airbridge Safety Inspections\Airbridge Safety Inspection 2023.xlsm")
closedbBook.Sheets("Data").Copy After:=ThisWorkbook.Sheets(1)
closedbBook.Close SaveChanges:=False
'Imports as "Data(3)" - would like it to be renamed to "Airbridge Operation Audit"
Set closedbBook = Workbooks.Open("\\gatwick\Group9\Airfield Operations\2023 Airfield Inspection and Data\Aircraft Turnaround Audits\Airbridge Operation Safety Audit 2023.xlsm")
closedbBook.Sheets("Data").Copy After:=ThisWorkbook.Sheets(1)
closedbBook.Close SaveChanges:=False
Application.ScreenUpdating = True
ActiveWorkbook.Save
Sheets("Master").Select
ActiveWorkbook.Save
MsgBox "Audit Data Copied For The Month"
End Sub
Thank you all