Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to map XML columns in a Excel spreadsheet using VBA

Status
Not open for further replies.

verylucky1

Programmer
Nov 22, 2010
2
US
Hi Folks, I have this requirement from my IT project that there is will be some XML files that need to be mapped to an Spreadsheet via VBA. Some XMLs will contain master data and some will contain detail data. Hence the columns on spreadsheet will not be in tabular format. They will be scattered at different rows and columns. Here are my requirements:

1- Map XML file columns to Excel cells.
2- XML files contain hundreds of rows so need to add a parameter on Excel that should bring one row of data for master and all detail rows.
3- Add a refresh button on the Excel that when clicked should refresh data from the XMLs.

Please let me know if you need more information or sample spreadsheet.
Thanks in advance for any direction and help.
 
Hi, You'll need to look in the vba help at the ImportXML method. Having done that, you'll need to look at the xmlmap object, and make sure that you have your schema set correctly. Once you've done that, the whole process should be fairly straightforward. As to the refresh button, you just need to attach the macro to it, or at least a stripped down version of it. Would be nice to see the xml and the kind of spreadsheet you are trying to create.
Take care,
PID
 
Hi, Thanks for responding. Do you happen to have some sample code that at least maps few columns? That would give me a jump start. Thanks in advance.
 


1. Read the VBA Help as directed.

2. TRY an IMPORT on the sheet. When you are comfortable with the process...

3. turn on your macro recorder and record the process.

Post back with your recorded code for further help customizing.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi again,
The importxml method is probably the way I'd go, but if you are using office 2003 or higher, there already exist tools that will help you, and take most of the donkey work out of the project. go to:
which describes what you should do far better than I can. I'd suggest that you want to check out the third option, which details how to build your map etc. Once you've done this, it should be easily recordable in a macro.
Best,
PID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top