Import Excel Data to Excel

tstone484

New Member
Joined
May 16, 2011
Messages
2
I am attempting to import multiple excel workbook tabs to a single workbook. I was able to accomplish this when converting a text file and importing but I am now getting a Runtime Error 5 with the following code. The code in red is where it is having an issue. Any help would be greatly appreciated. I am new to VB and coding for that matter so a number of simple issues keep confounding me.

Sub ImportBPStoActiveworksheet()
'
' ImportBPStoActiveworksheet Macro
'
Dim myPath As String
myPath = Application.GetOpenFilename()
Dim myConn As String
myConn = myPath
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & myConn, _
Destination:=Range("$A$2"))
'
.CommandType = xlCmdTable
.CommandText = Array("RTTMEOD")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True

.Refresh BackgroundQuery:=False
End With
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,216,077
Messages
6,128,679
Members
449,463
Latest member
Jojomen56

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