1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. 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...

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

Importing Files

Discussion in 'VBA Macros' started by RyujinLegacy, Apr 17, 2017.

  1. RyujinLegacy

    RyujinLegacy Member

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

    Attached Files:

  2. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
  3. vletm

    vletm Well-Known Member

    Messages:
    2,263
    Do RyujinLegacy has any clear logic, what to import and which layout?
    Do those 'Budget'-sheet data have any connection with this case?
  4. Monty

    Monty Well-Known Member

    Messages:
    635
    Hello RyujinLegacy

    Thanks for you PM.

    Can you give more information about your project..

    Thanks
    Monty!
  5. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    The Budget Sheet Will be Hiden ! But yea they have a litlle connection! But i just need to import the information of the Sample that i gave :)) (Transporte)
  6. vletm

    vletm Well-Known Member

    Messages:
    2,263
    Oh yeah!
    'Transporte' has four sheets with some rows data.
    and
    You want to copy all of those to 'Info'-sheet.
    really?
  7. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    No ! forget the Info-sheet !

    its just to copy all the sheets for the "ProgramaDavid"
  8. vletm

    vletm Well-Known Member

    Messages:
    2,263
    RyujinLegacy
    Nice case ...
    but would You write
    why You have open this case in other four sites too?

    Attached Files:

  9. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    i know men was my bad ... but im getting stressed out and i was needing alot of help :/ So i put this at another sites to get help faster !
  10. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    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 !

    :))
  11. Marc L

    Marc L Excel Ninja

    Messages:
    2,916
    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)
  12. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    Last edited by a moderator: Apr 18, 2017
  13. Marc L

    Marc L Excel Ninja

    Messages:
    2,916


    As a duplicate thread is against rules whatever the forum ! :rolleyes:
  14. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    How can i Delect this one?
  15. Marc L

    Marc L Excel Ninja

    Messages:
    2,916
    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 …
  16. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    So Marc Can u Help me?
  17. Marc L

    Marc L Excel Ninja

    Messages:
    2,916
    Seems an impossible mission without any answer to previous questions !
    As vletm yet started to help you …
  18. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    I guess he is helping ... But not right now :/ If u can help me to !
  19. Marc L

    Marc L Excel Ninja

    Messages:
    2,916


    So at least well read my previous post ! …​
  20. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    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 !
  21. Marc L

    Marc L Excel Ninja

    Messages:
    2,916
    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 ?
  22. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    Code (vb):
    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 (vb):
    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 :/
  23. vletm

    vletm Well-Known Member

    Messages:
    2,263
    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!
  24. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    ok ... Sorry Let me Try to do a Simple text ...
  25. RyujinLegacy

    RyujinLegacy Member

    Messages:
    31
    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

    Attached Files:

Share This Page