Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ANDRII_SAV1971
Regular Visitor

Power Quary and VBA code

Hi

How to connect VBA code in Data Query

Please give an exampe

 

Thank you

7 REPLIES 7
ZhangKun
Super User
Super User

Theoretically, this is possible, but there is a problem: when the power query plug-in is started, VBA will be blocked or unable to execute commands (especially in the same instance and the same file).

Possible implementation method: Use VBA to build a network service, Power Query sends a request to it (using Web.Contents), and the service performs operations based on the request content (but may be blocked or unable to execute commands).

Anonymous
Not applicable

Hi @ANDRII_SAV1971 ,
As they say, you can't go calling vba operations in power query. But you can trigger power query operations by using vba, you can refer to the following documentation for more specific details about the operation.

excel - How to automate a power query in VBA? - Stack Overflow

 

Best regards,
Albert He


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Omid_Motamedise
Super User
Super User

You can use the result of power query into Vba or reverse, you can also schedule the query refresh time by via but you can't access to the middle level steps of power query by vba

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
PwerQueryKees
Super User
Super User

From PowerQuery? Not possible I am afraid...

What are you trying to achieve?

PwerQueryKees
Super User
Super User

What do you want to achieve? You want to use VBA for excel I assume? It's possible to view  and change the content of a query or to create new queries. You can also Refresh tables based on a query. You cannot call VBA function from a query directly.

I had some good results with ChatGPT, but don't expect that to be first time right: You will still need to debug, simplify and understand the code yourself.

"I had some good results with ChatGPT"

 

Please write an example

 

Thank you

I want to run any VBA procedure

Call AAA("Hello")

Sub AAA(sNote as String)

    MsgBox sNote

End Sub

Can you clarify with an example?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors