ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to convert data (https://www.excelbanter.com/excel-programming/340322-macro-convert-data.html)

Sujith[_2_]

Macro to convert data
 
Hi,
On sheet named AREA has the follow data

A B C
ASD 22 3 4
BSD 6 7 8
CSD 9 11 8
EFD 16 19 8
GFD 27 27 8

Need to convert the data to the below format and then saved as xml
file. Any help with code or direction to where i could get this would be
greatly appreciated.
Can the code be created to convert a specific range of cells?


<data
<variable name="AREA"
<row
<column</column
<columnA</column
<columnB</column
<columnC</column
</row
<row
<columnASD</column
<column122</column
<column3</column
<column4</column
</row
<row
<columnBSD</column
<column116</column
<column7</column
<column8</column
</row
<row
<columnCSD</column
<column119</column
<column11</column
<column8</column
</row
<row
<columnEFD</column
<column16</column
<column19</column
<column8</column
</row
<row
<columnGFD</column
<column27</column
<column27</column
<column8</column
</row
</variable
</data


Regards,
Sujith

Vacation's Over

Macro to convert data
 
Excel 2003 does it automatically
DAtaXMLExport

"Sujith" wrote:

Hi,
On sheet named AREA has the follow data

A B C
ASD 22 3 4
BSD 6 7 8
CSD 9 11 8
EFD 16 19 8
GFD 27 27 8

Need to convert the data to the below format and then saved as xml
file. Any help with code or direction to where i could get this would be
greatly appreciated.
Can the code be created to convert a specific range of cells?


<data
<variable name="AREA"
<row
<column</column
<columnA</column
<columnB</column
<columnC</column
</row
<row
<columnASD</column
<column122</column
<column3</column
<column4</column
</row
<row
<columnBSD</column
<column116</column
<column7</column
<column8</column
</row
<row
<columnCSD</column
<column119</column
<column11</column
<column8</column
</row
<row
<columnEFD</column
<column16</column
<column19</column
<column8</column
</row
<row
<columnGFD</column
<column27</column
<column27</column
<column8</column
</row
</variable
</data


Regards,
Sujith


Sujith[_2_]

Macro to convert data
 
Vacation's Over wrote:
Excel 2003 does it automatically
DAtaXMLExport

"Sujith" wrote:


Hi,
On sheet named AREA has the follow data

A B C
ASD 22 3 4
BSD 6 7 8
CSD 9 11 8
EFD 16 19 8
GFD 27 27 8

Need to convert the data to the below format and then saved as xml
file. Any help with code or direction to where i could get this would be
greatly appreciated.
Can the code be created to convert a specific range of cells?


<data
<variable name="AREA"
<row
<column</column
<columnA</column
<columnB</column
<columnC</column
</row
<row
<columnASD</column
<column122</column
<column3</column
<column4</column
</row
<row
<columnBSD</column
<column116</column
<column7</column
<column8</column
</row
<row
<columnCSD</column
<column119</column
<column11</column
<column8</column
</row
<row
<columnEFD</column
<column16</column
<column19</column
<column8</column
</row
<row
<columnGFD</column
<column27</column
<column27</column
<column8</column
</row
</variable
</data


Regards,
Sujith

Thanks, but i am using excel 2002. Can this be achieved in 2002 to get
the above. I tried saving the sheet as xml spreadsheet but did not give
me the above structure, which is critical.
R/,
Sujith

Tim Williams

Macro to convert data
 
Just open a file from vba and write out the XML by looping through the
range.

eg (untested - treat as pseudocode)

dim rngOut as range,r as row, c as range

set rngOut=activesheet.range("A1:C10") 'for example

'....open file write the header info to file

'loop through content
for each r in rngOut.rows
'print to file "<row"
for each c in r.cells
'print to file "<column" & c.value & "</column"
next
'print to file "</row"
next r


Tim


"Sujith" wrote in message
...
Vacation's Over wrote:
Excel 2003 does it automatically
DAtaXMLExport

"Sujith" wrote:


Hi,
On sheet named AREA has the follow data

A B C
ASD 22 3 4
BSD 6 7 8
CSD 9 11 8
EFD 16 19 8
GFD 27 27 8

Need to convert the data to the below format and then saved as
xml file. Any help with code or direction to where i could get
this would be greatly appreciated.
Can the code be created to convert a specific range of cells?


<data
<variable name="AREA"
<row
<column</column
<columnA</column
<columnB</column
<columnC</column
</row
<row
<columnASD</column
<column122</column
<column3</column
<column4</column
</row
<row
<columnBSD</column
<column116</column
<column7</column
<column8</column
</row
<row
<columnCSD</column
<column119</column
<column11</column
<column8</column
</row
<row
<columnEFD</column
<column16</column
<column19</column
<column8</column
</row
<row
<columnGFD</column
<column27</column
<column27</column
<column8</column
</row
</variable
</data


Regards,
Sujith

Thanks, but i am using excel 2002. Can this be achieved in 2002 to
get the above. I tried saving the sheet as xml spreadsheet but did
not give me the above structure, which is critical.
R/,
Sujith




Sujith[_2_]

Macro to convert data
 
Tim Williams wrote:
Just open a file from vba and write out the XML by looping through the
range.

eg (untested - treat as pseudocode)

dim rngOut as range,r as row, c as range

set rngOut=activesheet.range("A1:C10") 'for example

'....open file write the header info to file

'loop through content
for each r in rngOut.rows
'print to file "<row"
for each c in r.cells
'print to file "<column" & c.value & "</column"
next
'print to file "</row"
next r


Tim

thx will try it out
Sujith


All times are GMT +1. The time now is 04:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com