Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

Excel find and replace macro


(!)

al_the_boss's Avatar
al_the_boss al_the_boss is offline
Member with 2 posts.
THREAD STARTER
 
Join Date: Jul 2012
16-Jul-2012, 08:17 AM #1
Excel find and replace macro
Hi I am complete noob but need some help ASAP (not sure if this is correct forum)
Basically I have an xml file, which I need to edit, see below (the * are just editted data, so work dont complain )
Quote:
<ORDERS> <ORDER> <ORDER_ID>**37597****</ORDER_ID> <ORDER_DATE>2011-10-26</ORDER_DATE> <ORDER_TYPE>STD</ORDER_TYPE> <CREDIT_CARD_NUMBER>5006</CREDIT_CARD_NUMBER> <DESPATCH_NOTE> <BRAND>GB</BRAND> </DESPATCH_NOTE> <RECIPIENT> <NAME><![CDATA[* *******]]></NAME> <EMAIL>********</EMAIL> <ADDRESS> <ADDRESS_LINE_1><![CDATA[The **** *****]]></ADDRESS_LINE_1> <ADDRESS_LINE_2><![CDATA[**** Head Yard]]></ADDRESS_LINE_2> <ADDRESS_LINE_3><![CDATA[]]></ADDRESS_LINE_3> <TOWN><![CDATA[FURNESS]]></TOWN> <COUNTY><![CDATA[******]]></COUNTY> <POSTCODE><![CDATA[**** *HF]]></POSTCODE> <COUNTRY>GB</COUNTRY> </ADDRESS> </RECIPIENT> <GIFT_MESSAGE> <GIFT_MESSAGE_LINE_1><![CDATA[5078]]></GIFT_MESSAGE_LINE_1> <GIFT_MESSAGE_LINE_2><![CDATA[20.00]]></GIFT_MESSAGE_LINE_2> <GIFT_MESSAGE_LINE_3><![CDATA[40.97]]></GIFT_MESSAGE_LINE_3> </GIFT_MESSAGE> <DELIVERY_LINE><ORDER_LINE_ID>1</ORDER_LINE_ID> <SKU>1365225</SKU> <QUANTITY>1</QUANTITY> <UNIT_PRICE CURRENCY="GBP"><VALUE>*.**</VALUE> </UNIT_PRICE> <DISCOUNT_PRICE CURRENCY="GBP"><VALUE>0.00</VALUE> </DISCOUNT_PRICE></DELIVERY_LINE> <ORDER_LINE> <ORDER_LINE_ID>1</ORDER_LINE_ID> <SKU>2302383</SKU> <QUANTITY>1</QUANTITY> <DESCRIPTION><![CDATA[**********]]></DESCRIPTION><UNIT_PRICE CURRENCY="GBP"><VALUE>****</VALUE> </UNIT_PRICE> <DISCOUNT_PRICE CURRENCY="GBP"><VALUE>****</VALUE> </DISCOUNT_PRICE></ORDER_LINE>
Ok, so that is the XML file, it will have this reoccuring for all the orders within that file.
Everytime it says
Quote:
<ORDER_LINE_ID>1</ORDER_LINE_ID> <SKU>2302383</SKU>
I want to replace the numbers between <SKU></SKU>, with another SKU from a list...
E.G. Find
Quote:
<ORDER_LINE_ID>1</ORDER_LINE_ID> <SKU>2302383</SKU>
Replace
Quote:
<ORDER_LINE_ID>1</ORDER_LINE_ID> <SKU>1234567</SKU>
The only reason I am struggling is because <SKU></SKU> occurs beneath
Quote:
<DELIVERY_LINE><ORDER_LINE_ID>1</ORDER_LINE_ID>
I dont want to alter this SKU as it is the DELIVERY SKU, I only wish to adjust the ITEM SKU (SKU above<DESCRIPTION><!)
So find and replace with a RANDOM SKU from a LIST.
E.G. 1234567, 8910111, 1213141, 5161718, 1920212 etc etc


I can copy the data stored in an XML file and just past into a single column in Excel.




Is this possible?
And if so would anyone mind showing?
THANKS in ADVANCE!
Zack Barresse's Avatar
Computer Specs
Member with 5,434 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
16-Jul-2012, 02:17 PM #2
Hi there, welcome to the board!

Do you have the xml file you can share/upload? I'm not really sure I understand why, but I think I understand how you want to do this. You just want a random number on the Item SKU, is that right? Then what, save it as a different file?
al_the_boss's Avatar
al_the_boss al_the_boss is offline
Member with 2 posts.
THREAD STARTER
 
Join Date: Jul 2012
17-Jul-2012, 04:17 AM #3
Hi zack
Basically we making some test data...We have these old xml files and only need to change the ITEM SKU's for our new testing. So we edit these lines and then push the editted xml file back through the system...

Er, I wanna replace the ITEM SKU's with a RANDOM sku from a designated list of about 80 new SKU's.
E.G. <ORDER_LINE_ID>1</ORDER_LINE_ID>
<SKU>1234567</SKU>

Replace <SKU>1234567</SKU> with a RANDOM SKU from the 'New SKU list'

New SKU list
<SKU>1111111</SKU>
<SKU>2222222</SKU>
<SKU>3333333</SKU>
<SKU>4444444</SKU>
<SKU>5555555</SKU>
<SKU>6666666</SKU>

I can paste this new list into the same excel file as the pasted XML code if needed.

Hope this makes sense now, and thanks for your time!
Zack Barresse's Avatar
Computer Specs
Member with 5,434 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
23-Jul-2012, 03:31 PM #4
Sorry for not getting back right away, it's been busy. Do you have the file for us to work with?
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2