Allow User to Select File | Power Query | M + VBA | Excel

Поділитися
Вставка
  • Опубліковано 14 жов 2024
  • Steps
    1. Create your query
    2. Name a specific cell
    3. Go to Visual Basic Editor, or Press Alt+F11
    4. Enter Code
    5. Create a button, or an Icon
    6. Assign macro to the button/icon
    7. Go to the Power Query Editor
    8. Open the Advanced Editor, and update the first few lines of code to reflect the following
    LocalPath = Excel.CurrentWorkbook(){[Name="FilePath"]}[Content]{0}[Column1], Source = Excel.Workbook(File.Contents(LocalPath), null, true),
    That's it!

КОМЕНТАРІ • 5

  • @excelnewb3488
    @excelnewb3488  3 роки тому +2

    on VBA
    Sub GetFilePath()
    Dim Path As Variant
    Path = Application.GetOpenFilename(Title:="Select File", FileFilter:="Excel Files (*.xls*),*.xls*")
    If Path False Then
    Sheet1.Range("C2").Value = Path
    End If
    End Sub

  • @Merok12332
    @Merok12332 5 місяців тому

    Great video for learning how to use VBA and some Power Query in practice.

  • @swapoj
    @swapoj Рік тому

    Wow, Thank you for the video.

  • @morih2402
    @morih2402 5 місяців тому

    Should I add the remain codes as I was trying to select different file with same column and format but not refreshing

  • @carlosalfaro5517
    @carlosalfaro5517 Рік тому

    Hey i tried using this solution for users to select more than 1 file, they are the same kind, hence idea is to append them altogether.
    Challenge am facing is that I cretaed 5 file paths, but user may not use 5 paths all the time. Hence when query is run it breaks due to value being null. Do you know a way to create some sort of conditional?