Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Formatting portions of a cell

Hi,

I was wondering (hoping) if there was a way to format text withing a cell --
below lists the formula that I have in the cell in question:

=CONCATENATE('Copy of Data for Graphs'!F15,": ",'Copy of Data for
Graphs'!J15," ",'2nd Level Sources & Conv'!F27,"
(",ROUND((E5/$E$89)*100,1),"%)")

What I'd like to do is the following:
- Apply a number format to the "'Copy of Data for Graphs'!J15" value so that
there are commas for every thousand (ie - so that 43456234 appears as
43,456,234)
- Apply a color to the font of "'Copy of Data for Graphs'!J15" so that it is
red while the font for the rest of the values in the cell remain black

I appreciate your help!

Thanks,

Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Formatting portions of a cell

Cells that contain formulas and cells that are numeric don't support this kind
of formatting.

You could change it to values and do what you want, though.

Linking to specific cells in pivot table wrote:

Hi,

I was wondering (hoping) if there was a way to format text withing a cell --
below lists the formula that I have in the cell in question:

=CONCATENATE('Copy of Data for Graphs'!F15,": ",'Copy of Data for
Graphs'!J15," ",'2nd Level Sources & Conv'!F27,"
(",ROUND((E5/$E$89)*100,1),"%)")

What I'd like to do is the following:
- Apply a number format to the "'Copy of Data for Graphs'!J15" value so that
there are commas for every thousand (ie - so that 43456234 appears as
43,456,234)
- Apply a color to the font of "'Copy of Data for Graphs'!J15" so that it is
red while the font for the rest of the values in the cell remain black

I appreciate your help!

Thanks,

Robert


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Formatting portions of a cell

Could anyone give an example of what the code to do this would look like?
I've been trying to write a macro that turns just selected text within a cell
a specific color with no success. I think the code should look something
like this:

Sub MakeBlue()
'
' MakeBlue Macro
' Macro recorded 02/06/2006 by MWalker
'
Selection.Characters.Font.ColorIndex = 41
End Sub

but it's not working. Any suggestions? Do I need to reference the specific
characters somehow?

"Dave Peterson" wrote:

Cells that contain formulas and cells that are numeric don't support this kind
of formatting.

You could change it to values and do what you want, though.

Linking to specific cells in pivot table wrote:

Hi,

I was wondering (hoping) if there was a way to format text withing a cell --
below lists the formula that I have in the cell in question:

=CONCATENATE('Copy of Data for Graphs'!F15,": ",'Copy of Data for
Graphs'!J15," ",'2nd Level Sources & Conv'!F27,"
(",ROUND((E5/$E$89)*100,1),"%)")

What I'd like to do is the following:
- Apply a number format to the "'Copy of Data for Graphs'!J15" value so that
there are commas for every thousand (ie - so that 43456234 appears as
43,456,234)
- Apply a color to the font of "'Copy of Data for Graphs'!J15" so that it is
red while the font for the rest of the values in the cell remain black

I appreciate your help!

Thanks,

Robert


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Formatting portions of a cell

Selection.Characters(Start:=3,length:=5).Font.Colo rIndex = 41

This does character 3 through 7 (5 characters).

michalaw wrote:

Could anyone give an example of what the code to do this would look like?
I've been trying to write a macro that turns just selected text within a cell
a specific color with no success. I think the code should look something
like this:

Sub MakeBlue()
'
' MakeBlue Macro
' Macro recorded 02/06/2006 by MWalker
'
Selection.Characters.Font.ColorIndex = 41
End Sub

but it's not working. Any suggestions? Do I need to reference the specific
characters somehow?

"Dave Peterson" wrote:

Cells that contain formulas and cells that are numeric don't support this kind
of formatting.

You could change it to values and do what you want, though.

Linking to specific cells in pivot table wrote:

Hi,

I was wondering (hoping) if there was a way to format text withing a cell --
below lists the formula that I have in the cell in question:

=CONCATENATE('Copy of Data for Graphs'!F15,": ",'Copy of Data for
Graphs'!J15," ",'2nd Level Sources & Conv'!F27,"
(",ROUND((E5/$E$89)*100,1),"%)")

What I'd like to do is the following:
- Apply a number format to the "'Copy of Data for Graphs'!J15" value so that
there are commas for every thousand (ie - so that 43456234 appears as
43,456,234)
- Apply a color to the font of "'Copy of Data for Graphs'!J15" so that it is
red while the font for the rest of the values in the cell remain black

I appreciate your help!

Thanks,

Robert


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Formatting portions of a cell

is it possible to format just a portion of the text in a cell without
referencing a specific character position? In the spreadsheet I'm
developing, I'd like to be able to highlight just a few words in a cell, and
hit a button to turn them a specific color. However, it won't be the same
word, or in the same place in the character string, in each cell. For
instance, we might want to color "dogs" in "Dogs are my favorite pet" in one
cell, and "Labrador" in "I have a Labrador" in the next.

"Dave Peterson" wrote:

Selection.Characters(Start:=3,length:=5).Font.Colo rIndex = 41

This does character 3 through 7 (5 characters).

michalaw wrote:

Could anyone give an example of what the code to do this would look like?
I've been trying to write a macro that turns just selected text within a cell
a specific color with no success. I think the code should look something
like this:

Sub MakeBlue()
'
' MakeBlue Macro
' Macro recorded 02/06/2006 by MWalker
'
Selection.Characters.Font.ColorIndex = 41
End Sub

but it's not working. Any suggestions? Do I need to reference the specific
characters somehow?

"Dave Peterson" wrote:

Cells that contain formulas and cells that are numeric don't support this kind
of formatting.

You could change it to values and do what you want, though.

Linking to specific cells in pivot table wrote:

Hi,

I was wondering (hoping) if there was a way to format text withing a cell --
below lists the formula that I have in the cell in question:

=CONCATENATE('Copy of Data for Graphs'!F15,": ",'Copy of Data for
Graphs'!J15," ",'2nd Level Sources & Conv'!F27,"
(",ROUND((E5/$E$89)*100,1),"%)")

What I'd like to do is the following:
- Apply a number format to the "'Copy of Data for Graphs'!J15" value so that
there are commas for every thousand (ie - so that 43456234 appears as
43,456,234)
- Apply a color to the font of "'Copy of Data for Graphs'!J15" so that it is
red while the font for the rest of the values in the cell remain black

I appreciate your help!

Thanks,

Robert

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Formatting portions of a cell

If you know the characters you want to highlight, you can use that in your code:

Option Explicit
Sub testme01()

Dim myStrToHighlight As String
Dim StartPos As Long

myStrToHighlight = "labrador"

With ActiveSheet.Range("A1")
.Value = "I have a Labrador dog" 'just for testing
StartPos = InStr(1, .Value, myStrToHighlight, vbTextCompare)

If StartPos 0 Then
.Characters(Start:=StartPos, Length:=Len(myStrToHighlight)) _
.Font.ColorIndex = 41
End If

End With

End Sub


michalaw wrote:

is it possible to format just a portion of the text in a cell without
referencing a specific character position? In the spreadsheet I'm
developing, I'd like to be able to highlight just a few words in a cell, and
hit a button to turn them a specific color. However, it won't be the same
word, or in the same place in the character string, in each cell. For
instance, we might want to color "dogs" in "Dogs are my favorite pet" in one
cell, and "Labrador" in "I have a Labrador" in the next.

"Dave Peterson" wrote:

Selection.Characters(Start:=3,length:=5).Font.Colo rIndex = 41

This does character 3 through 7 (5 characters).

michalaw wrote:

Could anyone give an example of what the code to do this would look like?
I've been trying to write a macro that turns just selected text within a cell
a specific color with no success. I think the code should look something
like this:

Sub MakeBlue()
'
' MakeBlue Macro
' Macro recorded 02/06/2006 by MWalker
'
Selection.Characters.Font.ColorIndex = 41
End Sub

but it's not working. Any suggestions? Do I need to reference the specific
characters somehow?

"Dave Peterson" wrote:

Cells that contain formulas and cells that are numeric don't support this kind
of formatting.

You could change it to values and do what you want, though.

Linking to specific cells in pivot table wrote:

Hi,

I was wondering (hoping) if there was a way to format text withing a cell --
below lists the formula that I have in the cell in question:

=CONCATENATE('Copy of Data for Graphs'!F15,": ",'Copy of Data for
Graphs'!J15," ",'2nd Level Sources & Conv'!F27,"
(",ROUND((E5/$E$89)*100,1),"%)")

What I'd like to do is the following:
- Apply a number format to the "'Copy of Data for Graphs'!J15" value so that
there are commas for every thousand (ie - so that 43456234 appears as
43,456,234)
- Apply a color to the font of "'Copy of Data for Graphs'!J15" so that it is
red while the font for the rest of the values in the cell remain black

I appreciate your help!

Thanks,

Robert

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Extract portions of text Lupe Excel Worksheet Functions 2 February 9th 10 01:57 PM
Conditional functions on portions of cell data sabow71 Excel Worksheet Functions 4 April 22nd 09 04:49 PM
Row & column portions of a cell as variables Tigerxxx Excel Discussion (Misc queries) 5 October 17th 08 08:21 PM
Change font in portions of cell with many characters (1000's) Barb Reinhardt Excel Discussion (Misc queries) 6 July 3rd 08 11:23 PM
Moving out Portions of Text from a Cell. Mikey Excel Programming 3 November 18th 04 03:52 AM


All times are GMT +1. The time now is 04:43 AM.

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"