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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Power Query Loaded Table - Change Data type through VBA

I have tables loaded on my Excel from Power Query. Some columns do not retain the data type and format I have specified in power query. For Example: Percentage type changes to Decimal(87.82%>0.878236484) and date type changes to Number(1/1/2020>43831) I hope to write VBA code to change the column data type by specifying the table name and column field header.

 

Kindly help with this.

 

Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello, @Jimmy801  Thank you for taking the time to reply to my question. Yes, i understand we would need to format the data type back on excel. I just wanted to automate that with VBA. I found the code to do that.

 

Thank you.

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

Power Query is loading the raw data to Excel. For a date this means a number and percentage is 0,xx. So the only way is to reformat your data in Excel once again. Don't forget to change the settings to keep changes of your format. So you don't need to write a VBA as long your column settings does change frequently.


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

Anonymous
Not applicable

Hello, @Jimmy801  Thank you for taking the time to reply to my question. Yes, i understand we would need to format the data type back on excel. I just wanted to automate that with VBA. I found the code to do that.

 

Thank you.

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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