Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Set text color to interior color

I have the following code:

Sub Test1()
Dim MyRange As Range
Dim MyColor As Integer
Dim MyCell As Integer

'' set range = to selected cells ''
Set MyRange = Selection

'' evaluate the value and apply to appropriate text color ''
For Each c In MyRange
c.Select
MyCell = ActiveCell.Value
Select Case MyCell
Case 0
Selection.Font.ColorIndex = 0
Case Else
Selection.Font.ColorIndex = 3
End Select
Next
End Sub

This code works fabulously, however, I would like to set the font colorindex
to the same value as the interior color index if the cell value is 0. Is
this possible, and how would I go about this ?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Set text color to interior color

This worked, I also tried a slight tweak to my own code, seting mycolor = to
the interior color and then if the value is o set the font colorindex = to
mycolor:

Thanks!

Sub Change_Color()
Dim MyRange As Range
Dim MyColor As Integer
Dim MyCell As Integer

MyColor = Selection.Interior.ColorIndex
Debug.Print MyColor
'' set range = to selected cells ''
Set MyRange = Selection

'' evaluate the value and apply to appropriate text color ''
For Each c In MyRange
c.Select
MyCell = ActiveCell.Value
Select Case MyCell
Case 0
Selection.Font.ColorIndex = MyColor
Case Else
Selection.Font.ColorIndex = 0
End Select
Next
End Sub


"Don Guillett" wrote:

try this
Sub docolors()
Selection.Font.ColorIndex = 3
For Each c In Selection
If c = 0 Then c.Font.ColorIndex = _
c.Interior.ColorIndex
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KJ-clueless" wrote in message
...
I have the following code:

Sub Test1()
Dim MyRange As Range
Dim MyColor As Integer
Dim MyCell As Integer

'' set range = to selected cells ''
Set MyRange = Selection

'' evaluate the value and apply to appropriate text color ''
For Each c In MyRange
c.Select
MyCell = ActiveCell.Value
Select Case MyCell
Case 0
Selection.Font.ColorIndex = 0
Case Else
Selection.Font.ColorIndex = 3
End Select
Next
End Sub

This code works fabulously, however, I would like to set the font
colorindex
to the same value as the interior color index if the cell value is 0. Is
this possible, and how would I go about this ?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Set text color to interior color

Your code uses unnecessary/undesirable selections.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KJ-clueless" wrote in message
...
This worked, I also tried a slight tweak to my own code, seting mycolor =
to
the interior color and then if the value is o set the font colorindex = to
mycolor:

Thanks!

Sub Change_Color()
Dim MyRange As Range
Dim MyColor As Integer
Dim MyCell As Integer

MyColor = Selection.Interior.ColorIndex
Debug.Print MyColor
'' set range = to selected cells ''
Set MyRange = Selection

'' evaluate the value and apply to appropriate text color ''
For Each c In MyRange
c.Select
MyCell = ActiveCell.Value
Select Case MyCell
Case 0
Selection.Font.ColorIndex = MyColor
Case Else
Selection.Font.ColorIndex = 0
End Select
Next
End Sub


"Don Guillett" wrote:

try this
Sub docolors()
Selection.Font.ColorIndex = 3
For Each c In Selection
If c = 0 Then c.Font.ColorIndex = _
c.Interior.ColorIndex
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KJ-clueless" wrote in message
...
I have the following code:

Sub Test1()
Dim MyRange As Range
Dim MyColor As Integer
Dim MyCell As Integer

'' set range = to selected cells ''
Set MyRange = Selection

'' evaluate the value and apply to appropriate text color ''
For Each c In MyRange
c.Select
MyCell = ActiveCell.Value
Select Case MyCell
Case 0
Selection.Font.ColorIndex = 0
Case Else
Selection.Font.ColorIndex = 3
End Select
Next
End Sub

This code works fabulously, however, I would like to set the font
colorindex
to the same value as the interior color index if the cell value is 0.
Is
this possible, and how would I go about this ?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Set text color to interior color

Help me understand what was unnecessary / undesirable ... I'm pretty new at
this.


"Don Guillett" wrote:

Your code uses unnecessary/undesirable selections.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KJ-clueless" wrote in message
...
This worked, I also tried a slight tweak to my own code, seting mycolor =
to
the interior color and then if the value is o set the font colorindex = to
mycolor:

Thanks!

Sub Change_Color()
Dim MyRange As Range
Dim MyColor As Integer
Dim MyCell As Integer

MyColor = Selection.Interior.ColorIndex
Debug.Print MyColor
'' set range = to selected cells ''
Set MyRange = Selection

'' evaluate the value and apply to appropriate text color ''
For Each c In MyRange
c.Select
MyCell = ActiveCell.Value
Select Case MyCell
Case 0
Selection.Font.ColorIndex = MyColor
Case Else
Selection.Font.ColorIndex = 0
End Select
Next
End Sub


"Don Guillett" wrote:

try this
Sub docolors()
Selection.Font.ColorIndex = 3
For Each c In Selection
If c = 0 Then c.Font.ColorIndex = _
c.Interior.ColorIndex
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"KJ-clueless" wrote in message
...
I have the following code:

Sub Test1()
Dim MyRange As Range
Dim MyColor As Integer
Dim MyCell As Integer

'' set range = to selected cells ''
Set MyRange = Selection

'' evaluate the value and apply to appropriate text color ''
For Each c In MyRange
c.Select
MyCell = ActiveCell.Value
Select Case MyCell
Case 0
Selection.Font.ColorIndex = 0
Case Else
Selection.Font.ColorIndex = 3
End Select
Next
End Sub

This code works fabulously, however, I would like to set the font
colorindex
to the same value as the interior color index if the cell value is 0.
Is
this possible, and how would I go about this ?




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
Interior color [email protected] Excel Programming 2 February 16th 07 09:33 PM
Highlight text (interior color) Abdul[_2_] Excel Programming 2 August 20th 06 12:40 PM
Cell background color (interior color) setting not working Martin E. Excel Programming 1 May 21st 06 07:00 PM
Interior color Paal Excel Programming 0 March 20th 06 02:51 PM
Passing Back Color to Interior Color ExcelMonkey[_190_] Excel Programming 1 March 22nd 05 04:27 PM


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