Importing Files

Ryujin

New Member
Joined
Apr 17, 2017
Messages
12
Good Morning Friends ,

I need help to get a fuction to import Excel Files with VBA ,
I need to import the File it is entered in a Worksheet with the Name "Info" .

For Help you I will send the Excel that im working and the Excel that I want to import
clear.png


Best Regards and ty
:)
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Something like this perhaps:-
Code:
Option Explicit

Public Sub ImportWorkbook()

  Dim wbImport As Workbook
  Dim wsImport As Worksheet
  
  Set wbImport = Workbooks.Open("[COLOR=#FF0000][B]C:\filename.xlsx[/B][/COLOR]"[COLOR=#FF0000][/COLOR], , True)   [COLOR=#008000] ' the workbook containing the sheet you want to import[/COLOR]

  Set wsImport = wbImport.Sheets("[COLOR=#FF0000][B]Sheet1[/B][/COLOR]")                             [COLOR=#008000] ' the first worksheet you want to import[/COLOR]
  wsImport.Move After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)

  Set wsImport = wbImport.Sheets("[COLOR=#FF0000][B]Sheet2[/B][/COLOR]")                             [COLOR=#008000] ' the second worksheet you want to import, etc[/COLOR]
  wsImport.Move After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)

  wbImport.Close SaveChanges:=False
  
End Sub
 
Upvote 0
Ryujin said:
Could u help me?
The Quote that u gived that not working

I tested it here and made sure it was working. Please show me the code you're using after you put the correct filename and sheetname in.

1. Did you paste it into a general code module?

2. How did you run the code?

3. Does it give you any error messages?

4. If you step through it, how far does it get?
 
Upvote 0
Imagine .
i have 3 files with the name ... Ola.xlsm Adeus.xlms obrigado.xlms .
i want to be able to import that Files !
BUUUT if in another day appears another one , the program accept it to without touching in the code
Basically we need to accept all files that i want :)

Ty for the Help Sr.
 
Upvote 0
The file that you want to import: is it a single worksheet?
 
Upvote 0
And do you want all of the sheets imported or just one?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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