Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default vba to convert htm tags

I am needing to use VBA to do this:
Find every cell in my sheet that is bold, and replace it with "^b" plus
whatever text is in the cell, and another "^b"

I also need to do the reverse: find any cell that has ^b in it, and remove
the ^b, and make that cell bold

I've tried figuring this out with the record macro feature, but it doesn't
seem to record some of the find/replace features correctly when working with
finding the bold font.
thanks, southernatheart

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default vba to convert htm tags

The problem might be easy if the entire cell was bold, but I suspect you want to bold just some of the text in a cell.

Some time ago I wrote something similar, which took what resembled html code, and applied it to an Excel cell.
http://vangelder.orcon.net.nz/excel/incellformat.zip

Let me know if that suits, otherwise reply and I'll see what can be done.

Cheers,
Rob


Southern at Heart wrote:
I am needing to use VBA to do this:
Find every cell in my sheet that is bold, and replace it with "^b" plus
whatever text is in the cell, and another "^b"

I also need to do the reverse: find any cell that has ^b in it, and remove
the ^b, and make that cell bold

I've tried figuring this out with the record macro feature, but it doesn't
seem to record some of the find/replace features correctly when working with
finding the bold font.
thanks, southernatheart

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default vba to convert htm tags

Try this and let me know what you think:

Sub BoldFonts()
Dim SearchRange As Range, Cell As Range, BoldFonts As Range, x%
Set SearchRange = Cells.SpecialCells(xlCellTypeConstants)
For Each Cell In SearchRange
If Cell.Font.Bold = True Then
If x = 1 Then
Set BoldFonts = Union(BoldFonts, Cell)
Else
Set BoldFonts = Cell
x = 1
End If
End If
Next Cell
BoldFonts.Select

For Each c In Selection
If c.Value < "" Then c.Value = "^b" & c.Value & "^b"
Next c

End Sub

Thanks!
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Southern at Heart" wrote:

I am needing to use VBA to do this:
Find every cell in my sheet that is bold, and replace it with "^b" plus
whatever text is in the cell, and another "^b"

I also need to do the reverse: find any cell that has ^b in it, and remove
the ^b, and make that cell bold

I've tried figuring this out with the record macro feature, but it doesn't
seem to record some of the find/replace features correctly when working with
finding the bold font.
thanks, southernatheart

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
name tags name tags Excel Discussion (Misc queries) 1 April 14th 10 01:29 PM
How do I convert HTML tags within cell to text? Datraveller Excel Programming 0 April 16th 08 05:02 PM
no smart tags No smart tags in excel 2007 spreadsheet New Users to Excel 1 October 2nd 07 04:17 PM
Smart tags reno Excel Discussion (Misc queries) 0 January 9th 06 10:32 PM
mp3 tags Darren Hill[_3_] Excel Programming 2 December 15th 05 11:41 PM


All times are GMT +1. The time now is 12:58 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"