Solved

Update Excel Spreadsheet with Data from XML File

Posted on 2013-11-20
8
756 Views
Last Modified: 2013-11-21
Hello -

I have an XML file that is generated by an Access database.  I need to update the existing rows with specific data from the xml file.

The Excel columns are
A - LnName
B - LnID
C - SiteInfo
D - Client

The fields in the XML file I need are
SiteInfo and Client

I need to look up the LnID from column B in the XML file and update columns C and D with the corresponding data from the XML file.  Similar to using a lookup formula.

I tried just importing the data from the XML and using an offset/match formula...  however, when I do that the data from the xml file loses it's formatting even though it looks right in the sheet that I imported the file to.  

So instead of looking like the below...

url - xxxxxxx
gd - xxxxxxx
dt - xxxxxxx

The data comes in like this...

url - xxxxxxxgd - xxxxxxxdt - xxxxxxx


I am somewhat familiar with VBA, but am definitely a novice, so any help you can provide would be awesome!

Thanks!
0
Comment
Question by:rsburge
  • 5
  • 3
8 Comments
 
LVL 17

Expert Comment

by:andrewssd3
ID: 39665149
It looks as though the xml data is not being imported correctly with the different elements in separate cells. It would really help if you could post an example of your xml file and the workbook you are using to import it it to. You should not have to use VBA for this provided your import splits up the data correctly.
0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 39665172
On a different tack, if you are exporting xml data from Access, could you not export it in Excel format, or csv, which may be easier to handle?
0
 

Author Comment

by:rsburge
ID: 39665758
Thank you for your feedback.
Let me look into the excel export.  The original reason we didn't do that is because it was truncating the data from the memo field and the only way to get around that was to do an xml export.

The data in the two fields is combined using VBA and the VBA inserts the vbcrlf to get the next line in the cell.

Originally it was going from Access to another access database on another system.

Now, several of the users do not have Access, so the next solution that they are willing to work with is an Excel spreadsheet.

I am not able to post the xml file because it contains usernames and passwords.
0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 39665807
OK - but I can't help without at least seeing the structure of the file - could you just post a section with sensitive data removed?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:rsburge
ID: 39665891
Attached is a sample of the xml, and the workbook sample.  

The Import tab is what the data looks like when I just do a straight import of the xml.

The Login tab is what the data looks like when I use the offset/match formula to pull the data in from the import tab.  You can see the data looks correct in the Import tab, but when the formula pulls it in, it is in a single line; I need it to stay formatted as it is in the Import tab.

Ultimately, when this is all complete, the user will be able to click on the lender name in the Active Lenders tab that will take them to the matching row on the Logins tab.  I think I know how to do this piece however, I may end up asking a new question if it doesn't work as I hope.

Thank you for your help.
xmlExportSample.xml
ExcelSample.xls
0
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 500 total points
ID: 39666700
OK I see the problem - it's not quite what I thought - your MATCH seems to lose the linefeed characters from the looked up value.  Luckily all you need to do to fix this is to format the cell alignment as 'Wrap text' on the format cells...alignment dialog.

Hope this helps

Stuart
0
 

Author Comment

by:rsburge
ID: 39667043
Oh my gosh...  now don't I feel really dumb.  :)

I can't believe I didn't check that.  I am usually REALLY good with Excel.

Thank you so much for catching this my mistake!
0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 39667157
No it wasn't stupid - Excel automatically applies that formatting when you import or put a line feed in manually with alt-enter, but it doesn't know to do it when the data comes from a reference in a formula. It puzzled me for a while

Glad it's working now
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now