View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Table Formatting by a Macro

I assume you want to make an HTML page with a table of Excel
data. Try something like the following:


Sub AAA()
Dim FNum As Integer
Dim FName As String
Dim Rng As Range
Dim Rw As Range
Dim FullRange As Range

Set FullRange = Range("A1:C3") '<<< CHANGE

FName = "H:\Test.htm" '<<< CHANGE
FNum = FreeFile()
Open FName For Output As #FNum
Print #FNum, "<HTML"
Print #FNum, "<TABLE"
For Each Rw In FullRange.Rows
Print #FNum, "<TR"
For Each Rng In Rw.Cells
Print #FNum, "<TD" & Rng.Text & "</TD"
Next Rng
Print #FNum, "</TR"
Next Rw
Print #FNum, "</TABLE"
Print #FNum, "</HTML"
Close #FNum
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Thejan Mendis" wrote in message
...
Hi all,

I hope somebody can help me on creating a small and very

helpful EXCEL
macro.

I have a excel document with table like content and I need to

create a macro
which will format each cell with <td*what ever the cell

vale</td and each
row with <tr*cells</tr

Example

a b c
1 2 5

<tr<tda</td<tdb</td<tdc</td</tr
<tr<td1</td<td2</td<td5</td</tr

if i can make apply this to selected range that will be much

better


Please help me................

THEJAN