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

Hi

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: 93
Default Auto Formatting Excel Macro

Thejan,
Assumed the activecell of the selection is the top left cell
and the column just right to the selection is empty

Sub MokatadaMay()
StCol = ActiveCell.Column
StRow = ActiveCell.row
NumOCols = Selection.Columns.Count
NumORows = Selection.Rows.Count
For i = StRow To StRow + NumORows - 1
For j = StCol To StCol + NumOCols - 1
Cells(i, StCol + NumOCols).Value = _
Cells(i, StCol + NumOCols).Value & "<td" & _
Cells(i, j).Value & "</td"
Next j
Cells(i, StCol + NumOCols).Value = _
"<tr" & Cells(i, StCol + NumOCols).Value & "</tr"
Next i
End Sub

HTH
Cecil

"Thejan Mendis" wrote in message
...
Hi

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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Formatting Excel Macro

hi Cecilkumara Fernando

Thanks lot, it's working perfectly and if you can please tell me how do
I put these new data (the taged cell) to a new sheet as they taged
automatically.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Auto Formatting Excel Macro

Thejan,
Is this what you want?

Sub MokatadaMay()
StCol = ActiveCell.Column
StRow = ActiveCell.row
NumOCols = Selection.Columns.Count
NumORows = Selection.Rows.Count
Set cursh = ActiveSheet
Sheets.Add after:=Sheets(Sheets.Count)
cursh.Activate
For i = StRow To StRow + NumORows - 1
For j = StCol To StCol + NumOCols - 1
Sheets(Sheets.Count).Cells(k + 1, 1).Value = _
Sheets(Sheets.Count).Cells(k + 1, 1).Value & "<td" & _
Cells(i, j).Value & "</td"
Next j
Sheets(Sheets.Count).Cells(k + 1, 1).Value = _
"<tr" & Sheets(Sheets.Count).Cells(k + 1, 1).Value & "</tr"
k = k + 1
Next i
End Sub

Cecil

"Thejan Mendis" wrote in message
...
hi Cecilkumara Fernando

Thanks lot, it's working perfectly and if you can please tell me how do
I put these new data (the taged cell) to a new sheet as they taged
automatically.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
How do I get Excel to stop auto-formatting? topsquark Excel Discussion (Misc queries) 2 March 31st 06 01:26 PM
How do I stop Excel auto formatting the text 3-4 as 04 Apr? ahughf Excel Discussion (Misc queries) 3 October 16th 05 10:58 AM
Auto Formatting an Excel Spreadsheet Ray Excel Discussion (Misc queries) 0 January 19th 05 09:57 PM
Auto-Formatting in Excel: changing values Nate Pickett Excel Programming 0 April 22nd 04 09:55 PM


All times are GMT +1. The time now is 11:00 PM.

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"