How to solve run-time error #9

Status
Not open for further replies.

Kenor

Board Regular
Joined
Dec 8, 2020
Messages
116
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

Need anyone's help to view this VBA code.

I'm not sure what's wrong. Repeated edits, but still came out error #9.

1647249083164.png


Sub datasheet()

Application.DisplayAlerts = False
Worksheets(Array("FG_Store Bundle", "FG _Ship Bundle")).Delete --> Is there something wrong here ??
Application.DisplayAlerts = True


Workbooks("FG_Store Bundle.csv").Worksheets("FG_Store Bundle").Copy After:=Workbooks("FG Database Bundle.xlsm").Worksheets("Database")
Workbooks("FG_Ship Bundle.csv").Worksheets("FG_Ship Bundle").Copy After:=Workbooks("FG Database Bundle.xlsm").Worksheets("FG_Store Bundle")


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 Bundle.xlsm").Activate
Worksheets("cover sheet").Activate

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
It looks like you have a space before the underscore in "FG _Ship Bundle" which I don't think should be there.
 
Upvote 0
Is this actually a different question than what you asked here:
How to import multiple csv files into one excel file ?
At that point all your sheet names had 2 underscores in them, a 2nd one before the work Bundle.
Worksheets(Array("FG_Pack_Bundle", "FG_Store_Bundle", "FG_Ship_Bundle", "FG_Pack_Bag", "FG_Store_Bag", "FG_Ship_Bag")).Delete
In which case your line should be:-
VBA Code:
Worksheets(Array("FG_Store_Bundle", "FG _Ship_Bundle")).Delete
 
Upvote 0
I have remove the underscore.

But still have error.. :(

Sub datasheet()

Application.DisplayAlerts = False

Worksheets(Array("FG Store Bundle", "FG Ship Bundle")).Delete
Application.DisplayAlerts = True


Workbooks("FG Store Bundle.csv").Worksheets("FG Store Bundle").Copy After:=Workbooks("FG Database Bundle.xlsm").Worksheets("Database")
Workbooks("FG Ship Bundle.csv").Worksheets("FG Ship Bundle").Copy After:=Workbooks("FG Database Bundle.xlsm").Worksheets("FG Store Bundle")


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 Bundle.xlsm").Activate
Worksheets("cover sheet").Activate

End Sub
 
Upvote 0
Is this actually a different question than what you asked here:
How to import multiple csv files into one excel file ?
At that point all your sheet names had 2 underscores in them, a 2nd one before the work Bundle.

In which case your line should be:-
VBA Code:
Worksheets(Array("FG_Store_Bundle", "FG _Ship_Bundle")).Delete
Yes, because it is still unresolved. So, I pulled out a few name sheets into just two.

Does it affect this VBA code if I remove all underscores on all sheet names?
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top