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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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