The Problem (Q-score 4, ranked #244th of 303 in the Excel VBA archive)
The scenario as originally posted in 2013
We are trying to export an excel table with “Denormalized Data” to xml. The table headers are as follows:
| AssetManager Code | AssetManager Date | Portfolio Code | Portfolio Name | MarketValue | NetCashFlow | Field | Field Code | Field Name |
The AssetManager Code and AssetManager Date are the same throughout, the rest of the columns contain variable data.
Here is an example of the xml output we want:
<AssetManager Code="PFM" Date="20130117">
<Portfolios>
<Portfolio Code="CC PSP" Name="Consilium Capital">
<MarketValue>5548056.51</MarketValue>
<NetCashFlow>0</NetCashFlow>
<UserFields>
<Field Code="AM UCGT" Name="AM daily Unrealised CG">4375</Field>
</UserFields>
</Portfolio>
<Portfolio Code="MM (FC)" Name="Money Market UT (FC)">
<MarketValue>28975149.6500735</MarketValue>
<NetCashFlow>0</NetCashFlow>
<UserFields>
<Field Code="UCGT" Name="AM daily Unrealised CG">0</Field>
</UserFields>
</Portfolio>
</Portfolios>
</AssetManager>
And our xsd file containing the mappings:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AssetManager">
<xs:complexType>
<xs:sequence>
<xs:element ref="Portfolios" />
</xs:sequence>
<xs:attribute name="Code" type="xs:string"/>
<xs:attribute name="Date" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:complexType name="FieldType">
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="Code" type="xs:string"/>
<xs:attribute name="Name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:element name="Portfolios">
<xs:complexType>
<xs:sequence>
<xs:element name="Portfolio">
<xs:complexType>
<xs:sequence>
<xs:element name="MarketValue" type="xs:decimal"/>
<xs:element name="NetCashFlow" type="xs:decimal"/>
<xs:element name="UserFields">
<xs:complexType>
<xs:sequence>
<xs:element name="Field" type="FieldType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Code" type="xs:string"/>
<xs:attribute name="Name" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
At the very least we’d like to know why excel considers data denormalised?
Any help will be much appreciated.
Why community consensus is tight on this one
Across 303 Excel VBA entries in the archive, the accepted answer here holds niche answer (below median) status — meaning voters are unusually aligned on the right fix.
The Verified Solution — niche answer (below median) (+8)
45-line Excel VBA pattern (copy-ready)
First of all, you have a problem with the posted XSD. The Portfolio should have the maxOccurs set to a value greater than 1 – otherwise you’re not matching the sample XML and you wouldn’t get the “denormalized data” error when verifying your map in Excel.
This article should explain common errors you get with Excel maps – yours included.
I guess what you did was to drag-drop the root – this will not work with repeating elements.
You may get around with what I did below; it may not work for your concrete example, but it should give you an idea.
Modified your XSD to account for repeating particles:
<?xml version="1.0" encoding="UTF-8"?>
<!-- XML Schema generated by QTAssistant/XSD Module (http://www.paschidev.com) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AssetManager">
<xs:complexType>
<xs:sequence>
<xs:element ref="Portfolios"/>
</xs:sequence>
<xs:attribute name="Code" type="xs:string"/>
<xs:attribute name="Date" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:complexType name="FieldType">
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="Code" type="xs:string"/>
<xs:attribute name="Name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:element name="Portfolios">
<xs:complexType>
<xs:sequence>
<xs:element name="Portfolio" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="MarketValue" type="xs:decimal"/>
<xs:element name="NetCashFlow" type="xs:decimal"/>
<xs:element name="UserFields">
<xs:complexType>
<xs:sequence>
<xs:element name="Field" type="FieldType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Code" type="xs:string"/>
<xs:attribute name="Name" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Drag the Code and Date only on the first sheet; rename that to something else if you want.

Drag Portfolios to another sheet.

Fill in some data and Export; this is what I got:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssetManager Code="a" Date="b">
<Portfolios>
<Portfolio Code="aa" Name="bb">
<MarketValue>10</MarketValue>
<NetCashFlow>100</NetCashFlow>
<UserFields>
<Field/>
</UserFields>
</Portfolio>
<Portfolio Code="aa" Name="bb">
<MarketValue>10</MarketValue>
<NetCashFlow>100</NetCashFlow>
<UserFields>
<Field/>
</UserFields>
</Portfolio>
</Portfolios>
</AssetManager>
It looks pretty close. It should help you move forward if not with the solution itself, then with your investigations.
When to Use It — classic (2013–2016)
Ranked #244th in its category — specialized fit
This pattern sits in the 98% tail relative to the top answer. Reach for it when your scenario closely matches the question title; otherwise browse the Excel VBA archive for a higher-consensus alternative.
What changed between 2013 and 2026
The answer is 13 years old. The Excel VBA object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.