Exported Powerquery CSV differs from Main exported Sheet

jamobe

New Member
Joined
Dec 23, 2014
Messages
36
Office Version
  1. 365
Platform
  1. Windows
Hi

I hope someone can help

I have a sheet that I export using VBA to convert it to csv using , as a delimeter. When I import this csv file using my 3rd party application, despite this csv file having plenty of commas within the file, the program still knows which columns to use and doesn't jumble the data around. I have been doing this successfully for ages. But now I would like to use a sheet created from power query and have that exported, but now when I export this as csv and then import to my 3rd party application it is jumbling all the data around where the commas are within the body. So I am assuming this csv does not export in the same format as the original. Here is the code I use to export the sheets. Any ideas would be much appreciated

Here is the code I use to export the sheets

Private Sub Export_LW_PQ_CSV_Btn_Click()
' Disable screen updating to improve performance
Application.ScreenUpdating = False
Application.DisplayAlerts = False ' Prevent overwrite alerts

' Refresh all data in the active workbook
ActiveWorkbook.RefreshAll

' Ask the user if they want to proceed with the export
Dim proceed As VbMsgBoxResult
proceed = MsgBox("Proceed With Exporting Inventory File To Linnworks Location?", vbQuestion + vbYesNo)

If proceed = vbYes Then
' Define the worksheet to export as CSV
Dim shtToExport As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("Master Products")

' Create a new workbook to copy the sheet
Dim wbkExport As Workbook
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)

' Save the copied sheet as a CSV file
wbkExport.SaveAs Filename:="C:\Users\xxxja\Dropbox\Linnworks Importing\Linnworks_Product_Export.csv", FileFormat:=xlCSV

' Ask the user if they want to open the file location
Dim openLocation As VbMsgBoxResult
openLocation = MsgBox("Do you want to open the file location?", vbQuestion + vbYesNo)

If openLocation = vbYes Then
' Open Windows file location
Dim folderPath As String
folderPath = "C:\Users\xxxja\Dropbox\Linnworks Importing\"
Shell "explorer.exe """ & folderPath & """", vbNormalFocus
End If

' Close the exported workbook without saving changes
wbkExport.Close SaveChanges:=False

' Notify the user about successful export
MsgBox "Linnworks CSV Export Successful", vbInformation, "Exporting"
End If

' Enable screen updating and re-enable alerts
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top