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.
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: