Tech Support Guy banner
Status
Not open for further replies.

Excel find and replace macro

2K views 3 replies 2 participants last post by  Zack Barresse 
#1 ·
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 )
<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> ******** <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> </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
<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
<ORDER_LINE_ID>1</ORDER_LINE_ID> <SKU>2302383</SKU>
Replace
<ORDER_LINE_ID>1</ORDER_LINE_ID> <SKU>1234567</SKU>
The only reason I am struggling is because <SKU></SKU> occurs beneath
<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!
 
See less See more
#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?
 
#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!
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top