Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Table Formatting by a Macro

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Excel Table and Pivot Table Formatting sanmos Excel Discussion (Misc queries) 0 February 9th 10 12:07 AM
Excel 2007 Macro specific table to generic table? Sue Excel Discussion (Misc queries) 3 June 1st 08 06:12 PM
Conditional formatting in a table is lost on table refresh Steve Huckett Excel Worksheet Functions 0 November 6th 07 11:39 AM
Pivot Table border formatting and pivot chart formatting [email protected] Excel Discussion (Misc queries) 0 July 22nd 05 02:22 PM
Steps from Macro recorder for Pivot table will not run as a Macro Nancy[_5_] Excel Programming 0 April 2nd 04 10:33 PM


All times are GMT +1. The time now is 05:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"