Hi guys, I need help with VBA for button to export .xml table by selection.
I tried to copy and combine some example code but with no luck.
It creates .xml but not for selection or fixed range (never mind) but the data is wrong as I don't know how to code it properly...
The code is:
What I need is a creation of .xml file with two columns of data from selected cells or entire table (fixed, never mind which one is it) after clicking the button.
If you guys can help, It would be a life saver
Thank you all in advance !!!
I tried to copy and combine some example code but with no luck.
It creates .xml but not for selection or fixed range (never mind) but the data is wrong as I don't know how to code it properly...
The code is:
Code:
Private Sub Xml_click()
Dim myFile As String, rng As Range, cellValue As Variant, i As Integer, j As Integer
myFile = ActiveWorkbook.Path & "\Popis.xml"
Set rng = Selection
Open myFile For Output As #1
For i = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Count
cellValue = rng.Cells(i, j).Value
If j = rng.Columns.Count Then
Write #1, cellValue
Else
Write #1, cellValue,
End If
Next j
Next i
Close #1
End Sub
If you guys can help, It would be a life saver
Thank you all in advance !!!