VBA to copy row, export as XML and go on copying rows

Mimosa

New Member
Joined
Apr 16, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hey!

I have excel .xlsx workbook with loaded xml source. I take one row from sheet "Clients" and copy it to row "Data", then export is as XML with name changed according the data from the copied row and then use it in other ways. I have found one VBA in this forum that helped me solve the copying part:

Sub copyrows()
Dim i As Long
With Sheets("Clients")
For i = 2 To .Range("A" & Rows.Count).End(3).Row
If WorksheetFunction.Trim(.Range("A" & i).Value) = "" Then Exit Sub
.Rows(i).Copy Sheets("Data").Range("A2")
ThisWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & .Range("G" & i) & " " & .Range("F" & i) & ".xml"
Next
End With
End Sub

The issue with this is, that the .xml file after is unusable for me. There's not the right code and instead get weird signs or numbers. I've tried Workbook.SaveAsXMLData with some options but that didn't work (always some mistake in the code). So does anyone have an idea how to deal with this?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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