Hi All,
Anyone can help to confirm below VBA code for above matter?
Sub datasheet()
Application.DisplayAlerts = False
Worksheets(Array("FG_Pack_Bundle", "FG_Store_Bundle", "FG_Ship_Bundle", "FG_Pack_Bag", "FG_Store_Bag", "FG_Ship_Bag")).Delete
Application.DisplayAlerts = True
Workbooks("FG_Pack_Bundle.csv").Worksheets("FG_Pack_Bundle").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("Database")
Workbooks("FG_Store_Bundle.csv").Worksheets("FG_Store_Bundle").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Pack_Bundle")
Workbooks("FG_Ship_Bundle.csv").Worksheets("FG_Ship_Bundle").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Store_Bundle")
Workbooks("FG_Pack_Bag.csv").Worksheets("FG_Pack_Bag").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Ship_Bundle")
Workbooks("FG_Store_Bag.csv").Worksheets("FG_Store_Bag").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Pack_Bag")
Workbooks("FG_Ship_Bag.csv").Worksheets("FG_Ship_Bag").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Store_Bag")
Dim bk As Workbook
For Each bk In Workbooks
If Not (bk Is ThisWorkbook) Then
bk.Close SaveChanges:=False
End If
Next
Workbooks("FG_Database.xlsm").Activate
Worksheets("cover sheet").Activate
End Sub
Before this, I create another Database using same VBA code. So far, no problem.
Only this time, it shows this error.
--> Run-time error '9':
Subscript out of range
And its refer to this sentences.
Sub datasheet()
Application.DisplayAlerts = False
--> Worksheets(Array("FG_Pack_Bundle", "FG_Store_Bundle", "FG_Ship_Bundle", "FG_Pack_Bag", "FG_Store_Bag", "FG_Ship_Bag")).Delete
Application.DisplayAlerts = True
Hope anyone can help.
Thanks
Anyone can help to confirm below VBA code for above matter?
Sub datasheet()
Application.DisplayAlerts = False
Worksheets(Array("FG_Pack_Bundle", "FG_Store_Bundle", "FG_Ship_Bundle", "FG_Pack_Bag", "FG_Store_Bag", "FG_Ship_Bag")).Delete
Application.DisplayAlerts = True
Workbooks("FG_Pack_Bundle.csv").Worksheets("FG_Pack_Bundle").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("Database")
Workbooks("FG_Store_Bundle.csv").Worksheets("FG_Store_Bundle").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Pack_Bundle")
Workbooks("FG_Ship_Bundle.csv").Worksheets("FG_Ship_Bundle").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Store_Bundle")
Workbooks("FG_Pack_Bag.csv").Worksheets("FG_Pack_Bag").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Ship_Bundle")
Workbooks("FG_Store_Bag.csv").Worksheets("FG_Store_Bag").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Pack_Bag")
Workbooks("FG_Ship_Bag.csv").Worksheets("FG_Ship_Bag").Copy After:=Workbooks("FG_Database.xlsm").Worksheets("FG_Store_Bag")
Dim bk As Workbook
For Each bk In Workbooks
If Not (bk Is ThisWorkbook) Then
bk.Close SaveChanges:=False
End If
Next
Workbooks("FG_Database.xlsm").Activate
Worksheets("cover sheet").Activate
End Sub
Before this, I create another Database using same VBA code. So far, no problem.
Only this time, it shows this error.
--> Run-time error '9':
Subscript out of range
And its refer to this sentences.
Sub datasheet()
Application.DisplayAlerts = False
--> Worksheets(Array("FG_Pack_Bundle", "FG_Store_Bundle", "FG_Ship_Bundle", "FG_Pack_Bag", "FG_Store_Bag", "FG_Ship_Bag")).Delete
Application.DisplayAlerts = True
Hope anyone can help.
Thanks