Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

VBA update power query

0

hello

I'm  asking  about   update power query by  vba   .

I search  for  some  code lines   to  put  into   workbook  open event    to  update  automatically   instead  of  refresh manually from  inside the  sheet  by  right click  and  refresh .

any  guys  have  idea ?

Answer
Discuss

Answers

0
Selected Answer

Hi Halk

If you have a power query table on (VBA) Sheet1 and cell B2 is within that result, this will work:

Private Sub Workbook_Open()

Sheet1.Range("B2").ListObject.QueryTable.Refresh BackgroundQuery:=False
MsgBox "Power query updated on opening"

End Sub
You don't need the message box and need to change the bits in bold to suit you. Also you could replace Sheet1 with Worksheets("yourSheetName") if you like.

Hope this works for you.

Discuss

Discussion

very great !  many  thank.
Halk (rep: 28) Dec 5, '21 at 5:43 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login