+ Reply to Thread
Results 1 to 7 of 7

Getting Power Query data to an Excel worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    03-30-2024
    Location
    Kansas City MO
    MS-Off Ver
    Excel 365
    Posts
    4

    Re: Getting Power Query data to an Excel worksheet

    Solution found for my situation:

    After I create my blank sheet and have loaded the query, and the data is there as a connection only query.

    Add this line:

    LoadQuery "QueryName", ActiveSheet
    QueryName is the name you used when creating the query.



    Then have the following Private Sub

    Private Sub LoadQuery(ByVal QueryName As String, ByVal LoadDataSheet As Worksheet)
    
        With LoadDataSheet.ListObjects.Add(SourceType:=0, Source:= _
                                         "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=" & QueryName & ";Extended Properties=""""", _
                                         Destination:=LoadDataSheet.Range("$A$1")).QueryTable
    
            .CommandType = xlCmdSql
            .CommandText = Array("SELECT * FROM [" & QueryName & "]")
       
    
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = False
            .RefreshStyle = xlOverwriteCells
            .SavePassword = False
            .SaveData = False
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .PreserveColumnInfo = True
            .ListObject.DisplayName = "Table_" & QueryName
            .Refresh BackgroundQuery:=False
    
        End With
    
    End Sub


    This will take all your data from the query and dump it into a sheet.
    I cannot take credit for the solution, found on another site, but thought it might be helpful to others.
    Last edited by MichaelMorris; 04-01-2024 at 03:15 PM. Reason: Solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Power Query: data difference PQ screen vs Excel worksheet
    By jonas-martens in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-07-2024, 08:32 AM
  2. Replies: 5
    Last Post: 10-31-2023, 11:12 AM
  3. [SOLVED] Why is my Excel file so big even though I uploaded the data using Power Pivot/Power Query?
    By Olivia Ludwig in forum Excel Charting & Pivots
    Replies: 12
    Last Post: 09-21-2023, 05:18 AM
  4. [SOLVED] Power Query - excel formula translation into Power Query
    By afgi in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 02-19-2020, 03:38 AM
  5. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  6. Excel Power Query Refresh or Access Query - 2nd Query Run is faster
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2020, 10:16 AM
  7. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1