Excel vba import data

Status
Not open for further replies.

themluis

New Member
Joined
Jun 12, 2015
Messages
33
Hey guys I'm a newbie on the VBA, and I need to do a project for the company I work. Every thing was going very good until I knew that I was going to need to import information from another excel file to the one I'm developing.

And they said I need to take the information out of 3 columns, and put it in my file, and there's a part that seems very difficult, the other file as 2 sheets and the information is separated between the two sheets.

I was trying to do it but it gives me alot of errors like the file location it's correct, and to resume the problems with it by a word "Mess".

hope you guys could help me out on this. It's my first post, sorry if the information is not very clear, ask anything to help you guys out.

Code:
Sub Pesquisa()
Dim directory As String, fileName As String, sheet As Worksheet, total As Integer

Application.ScreenUpdating = False
Application.DisplayAlerts = False

directory = "\\C:\Users\DZPH8SH\"
fileName = Dir(directory & "Status 496 800 semana 12 2015")

Do While fileName <> ""

Loop

Workbooks.Open (directory & fileName)

For Each sheet In Workbooks(fileName).Worksheets
    total = Workbooks("import-sheets.xls").Worksheets.Count
    Workbooks(fileName).Worksheets(sheet.Name).Copy _
    after:=Workbooks("import-sheets.xls").Worksheets(total)
Next sheet

Workbooks(fileName).Close

fileName = Dir()

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Status
Not open for further replies.

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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