VBA to XML Macro

jc0r

Board Regular
Joined
Mar 16, 2009
Messages
124
Hi all

I am trying to create a macro that takes values from an input worksheet, compiles them into a valid XML, then writes this XML to an output worksheet.

The XML Schema (think thats the right word for it :oops:) looks like the following

XmlNotepad_wUzB1chEt9.png

The values from the input sheet look like the following

EXCEL_3EKMrMUhFu.png


These are horse races with H5:H14 being the runners (selections) of race 1 with cloth number referenced in column G, I5:I25 race 2 etc.

The amount of runners on a given day are dynamic so i need to loop until.

I would like the macro to fill in the selections and cloth numbers for each race, again, the amount of races can also change (in this example, there is no race 7 or 8).

On my output sheet, i would like to print something along the lines of the following based on the above example.

Can anyone offer any assistance with this please.

Kind regards

XML:
<ArrayOfCompactEventClassifier>
<CompactEventClassifier Name="Great Trethew" IsStartTimeSet="true" StartTime="2023-11-18T15:22:00+00:00" >
 <ChildEventClassifiers/>
<Markets>
<CompactMarket Name="12:00" StartTime="2023-11-18T12:00:00+00:00" >
<Selections>
 <CompactSelection Name="DEVON RED" ClothNumber="1" />
 <CompactSelection Name="DUNADEN ISLAND" ClothNumber="2" />
 <CompactSelection Name="HOLESHOT" ClothNumber="3" />
 </Selections>
 </CompactMarket>
 </Markets>
 </CompactEventClassifier>
 </ArrayOfCompactEventClassifier>
 

Attachments

  • xml.png
    xml.png
    18.2 KB · Views: 7
  • EXCEL_mkd8bNIHVJ.png
    EXCEL_mkd8bNIHVJ.png
    53.1 KB · Views: 6
  • EXCEL_R2KDL8yGPS.png
    EXCEL_R2KDL8yGPS.png
    52.7 KB · Views: 6
  • EXCEL_R2KDL8yGPS.png
    EXCEL_R2KDL8yGPS.png
    52.7 KB · Views: 7
  • EXCEL_mkd8bNIHVJ.png
    EXCEL_mkd8bNIHVJ.png
    53.1 KB · Views: 6

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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