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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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