• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Importing Files

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

Best Regards and ty :))
 

Attachments

  • ProgramaDavid.xlsm
    26.2 KB · Views: 4
  • Transporte 2017 TESTE.xlsm
    143.5 KB · Views: 4
Oh yeah!
'Transporte' has four sheets with some rows data.
and
You want to copy all of those to 'Info'-sheet.
really?
 
Hm @vletm its not working like i wanted :/
Let me try to Explain better my self .

I need to Import Aloteeeee of files ! Not just the "Transporte 2017 TESTE" so thats the first think !

And ignore the info Sheet!
I want to import all the sheets of the file that i put !
Imagine , if i have got 3 sheets on the file that i want to import !
In the "ProgramaDavid" Will appear the sheets of the File that i import !

:))
 
Hi !

Let me explain few points !

• First, initial post must detail the need and you never wrote
about importing a lot of files but « the File » ‼

• Second, wild cross-posting is a waste of time 'cause nobody wants
to take time to answer in case of any answer on any other forum !

So it is far better to take time to create a thread on an unique forum
with at least a crystal clear and complete initial post
with attachment reflecting exactly real files & data
with source data and expected result
than a poor post on many forums even with useless private messages !

The better initial post & attachment, the better and quicker solution …

If you can’t explain it simply, you don’t understand it well enough … (Albert Einstein)
 
New thread deleted as duplicate and again
without any information about cross-posting ‼
You do not follow any rule or what ?!

If you wanna stay on this forum,
continue here bringing finally all the needed …
 
So i want to import the some xlsm files .
What kind of layout?

So the project its for study some data , for a Company.

Basically i need to import XLSM files and next study the Values ... But i need to start with the import !
 
Some people call me The Doctor
but as we are not on a mind readers forum
we need a technical explanation …

And without, I won't waste time anymore on this thread
as I had a call from my Tardis.
But maybe could you understand with the help of a Dalek ?
 
Code:
Private Sub Btn_1_Click()

    Application.ScreenUpdating = False

    Dim Src As String
    Dim c As Range
   
    Src = GetFile("C:\")
   
    If Src = "" Then
        Exit Sub
    End If
   
    With ThisWorkbook.Sheets("Entradas")
        .Cells.ClearContents
        Workbooks.OpenXML Src
        Sheets(1).UsedRange.Copy ThisWorkbook.Sheets("Entradas").Cells(1, 1)
        ActiveWorkbook.Close False
        .Activate
    End With
    MsgBox "Informação de ""Entradas"" importada com sucesso!"
   
    Application.ScreenUpdating = True
   
End Sub
Code:
Function GetFile(strPath As String) As String

    Dim File As FileDialog
    Dim sItem As String
    Set File = Application.FileDialog(msoFileDialogFilePicker)
    With File
        .Title = "Selecione o ficheiro a importar"
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "Ficheiros CSV apenas", "*.csv"
        .InitialFileName = strPath
        If .Show <> -1 Then GoTo NextCode
        sItem = .SelectedItems(1)
    End With
NextCode:
    GetFile = sItem
    Set File = Nothing

End Function


Thats the code i have ... For The Csvs its working ... But i tried to chance for xlsm but dont work :/
 
RyujinLegacy ... You wrote like...
I need to import the File it is entered in a Worksheet with the Name "Info" .
its just to copy all the sheets for the "ProgramaDavid"
its not working like i wanted :/I tried to help You, but ...
do You really know what do You want?
Think twice three times and write once!
Read Your text Yourself. Delete it.
Think again twice three times and write again.
Read Your text and
if You really think that would be okay then...
press [Post Reply]
ps. If You feel stressed
... rest
... panic won't help You at all!
 
So From the Begin .

I have Files that i want to import. That Files have alot of sheets .
And i need to Put all that sheets in one when i import them, that imported info should be on the WorkSheet "Info".

The UserForm Name Its "Importar" and the button its "Importar Dados".

I will send the program and One File to import (to test it).

The Name of the program is "ProgramaDavid" and the file its the another one.

Points-->

I need to import all the Files that i want, because i will get alot of Files to import with diferent names. So dont put just for the "Transporte".

@vletm @Marc L @Monty
 

Attachments

  • ProgramaDavid.xlsm
    38 KB · Views: 3
  • Transporte.xlsm
    143.5 KB · Views: 3
Back
Top