Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 788
Default un-Bold part of text in a cell (automatically)

I have a variable length text in a column of cells where I want some of the
text to stand out differently than other parts. I want to make some bold and
some not. I want the location areas between parentheses, including the
parens, to be non-bold.

FedEx Ground (PA, USA) ; FedEx (TN, USA) ; FedEx Kinko's (CA, USA) ; Fedex
Freight East (AR, USA)

I can bold the whole thing then somehow take the bold off the parens, or
vice versa..

Can you tell me how to do that?

Thanks in Advance!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default un-Bold part of text in a cell (automatically)

Paste the following code into a VBA module in an open workbook. Select one
cell (at a time) which should be bolded/unbolded. From the Tools menu, select
Macro Macros BoldUnbold Run.

Sub BoldUnbold()
Dim Rx As String, x As Integer
Dim UnboldNow As Boolean
Rx$ = ActiveCell.FormulaR1C1
UnboldNow = False
For x% = 1 To Len(Rx$)
Select Case Mid(Rx$, x%, 1)
Case "("
With ActiveCell.Characters(Start:=x%, Length:=1).Font
.FontStyle = "Regular"
End With
UnboldNow = True
Case ")"
With ActiveCell.Characters(Start:=x%, Length:=1).Font
.FontStyle = "Regular"
End With
UnboldNow = False
Case Else
If UnboldNow = True Then
With ActiveCell.Characters(Start:=x%, Length:=1).Font
.FontStyle = "Regular"
End With
Else
With ActiveCell.Characters(Start:=x%, Length:=1).Font
.FontStyle = "Bold"
End With
End If
End Select
Next x%
End Sub

Hope this helps,

Hutch

"chris" wrote:

I have a variable length text in a column of cells where I want some of the
text to stand out differently than other parts. I want to make some bold and
some not. I want the location areas between parentheses, including the
parens, to be non-bold.

FedEx Ground (PA, USA) ; FedEx (TN, USA) ; FedEx Kinko's (CA, USA) ; Fedex
Freight East (AR, USA)

I can bold the whole thing then somehow take the bold off the parens, or
vice versa..

Can you tell me how to do that?

Thanks in Advance!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default un-Bold part of text in a cell (automatically)

Chris,

The following code will make bold text within parentheses (including the
parens). Select the range of cells to modify and then run the macro. The
text in each cell should NOT be bold in any way when you run the code.

Sub BoldParens()

Dim Pos1 As Long
Dim Pos2 As Long
Dim Rng As Range
For Each Rng In Selection.Cells
With Rng
If .HasFormula = False Then
Pos1 = 1
Pos2 = 1
Pos1 = InStr(1, .Value, "(")
Do Until Pos1 = 0
Pos2 = InStr(Pos1, .Value, ")")
If Pos2 0 Then
.Characters(Pos1, Pos2 - Pos1 + 1).Font.Bold = True
Else
Exit Do
End If
Pos1 = InStr(Pos2 + 1, .Value, "(")
Loop
End If
End With

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"chris" wrote in message
...
I have a variable length text in a column of cells where I want some of the
text to stand out differently than other parts. I want to make some bold
and
some not. I want the location areas between parentheses, including the
parens, to be non-bold.

FedEx Ground (PA, USA) ; FedEx (TN, USA) ; FedEx Kinko's (CA, USA) ; Fedex
Freight East (AR, USA)

I can bold the whole thing then somehow take the bold off the parens, or
vice versa..

Can you tell me how to do that?

Thanks in Advance!


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
how do i make one part of my formula bold and the other normal? niquey Excel Worksheet Functions 6 March 27th 06 03:22 PM
Join bold and non-bold text in one cell bkincaid Excel Discussion (Misc queries) 3 March 21st 06 12:58 AM
bold part of cell unavailable at time DrB Excel Worksheet Functions 3 January 15th 06 09:04 PM
Automatically outline all email addresses in a given text by putting them in red-bold frenchbox Excel Discussion (Misc queries) 1 December 26th 05 06:34 PM
Bold part of formula results Rita Palazzi Excel Discussion (Misc queries) 4 December 16th 04 07:51 PM


All times are GMT +1. The time now is 01:32 PM.

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

About Us

"It's about Microsoft Excel"