Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Avoid Table selection on Query Refresh - Power Query

I have a couple of Power Query tables that i refresh on selecting dropdowns with VBA in `Workbook_SheetChange()`. However, whenever the Query refreshes, the table gets selected. I tried using `Applic...
  • Jimmy801's avatar
    Jimmy801
    5 years ago

    Hello  Anonymous 

     

    try this code

     

    Option Explicit
    
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    
        Dim Con As String
        
        If Target.Address = "$B$2" Then
            Con = "Query - tblOriginal"
    
        
            Sheet1.ListObjects(1).QueryTable.Refresh BackgroundQuery:=False
            
    
            
            Application.OnTime Now() + TimeSerial(0, 0, 3), "SelectB2"
            
            'Application.Goto Sh.Cells(2,"B")
            'Sh.Cells(2, "B").Select
        End If
    
    End Sub
    
    

     

     

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy