View Full Version : Font color
josephm
06-13-2008, 10:23 AM
i need a colour platte on each within a range of cells is there an add-in for this?
josephm
06-13-2008, 10:47 AM
how can i right click on an active cell and change the font color of the cell's content without clicking format cells?
marshybid
06-13-2008, 10:50 AM
how can i right click on an active cell and change the font color of the cell's content without clicking format cells?
You don't need to right click on the cell to change the interior or font color.
If you look along your excel toolbar you will see a button for Font Colour and a button for interior color, just click on these and select the color. If you don't see these buttons, right click in your toolbar area click customize, then drag and drop the buttons you need to add
Marshybid
josephm
06-13-2008, 10:58 AM
thank you but i do want the user to have to go all the way up there
isnt there a add-in similar to the pop-up calander?
lenze
06-13-2008, 11:04 AM
This will toggle the Font between xlAutomatic and Red with a Right Click
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Target.Font.ColorIndex = xlAutomatic Then
Target.Font.ColorIndex = 3
Else: Target.Font.ColorIndex = xlAutomatic
End If
Cancel = True
End Sub
I think it best to use a BeforeDoubleClick instead. This maintains your Right Click Menu
lenze
josephm
06-13-2008, 11:15 AM
i want the user to pick either red or green. how do i do that using the above code.?
and from the right click menu how does the user select red or green?
lenze
06-13-2008, 11:17 AM
I don't understand your question? Can you give an example of your needs?
lenze
josephm
06-13-2008, 11:24 AM
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Font.ColorIndex = xlAutomatic Then
Target.Font.ColorIndex = 3
Target.Font.ColorIndex = 4
Else: Target.Font.ColorIndex = xlAutomatic
End If
Cancel = True
End Sub
i made a change to the code as shown above but then it only toggles between XLautomatic and green it leave out the red.
i want it to toggle beteen automatic, red and green.
lenze
06-13-2008, 11:28 AM
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean
If Target.Font.ColorIndex = 4 Then
Target.Font.ColorIndex = 3
Else: Target.Font.ColorIndex = 4
End If
Cancel = True
End Sub
You just need to change to the appropriate ColorIndex Number. To see all the CI's on your computer, place this code in a regular modue and run it on a blank sheet
Sub ShowColorIndex()
Dim cl As Range
Dim x As Integer
x = 0
Range("$A$3:$A$17").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ColumnWidth = 17.5
.RowHeight = 20
.Font.Bold = True
End With
For Each cl In Selection
cl.Value = x
cl.Interior.ColorIndex = x
x = x + 1
Next cl
Range("$C$4:$C$17").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ColumnWidth = 17.5
.Font.Bold = True
End With
For Each cl In Selection
cl.Value = x
cl.Interior.ColorIndex = x
x = x + 1
Next cl
Range("$E$4:$E$17").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ColumnWidth = 17.5
.Font.Bold = True
End With
For Each cl In Selection
cl.Value = x
cl.Interior.ColorIndex = x
x = x + 1
Next cl
Range("$G$4:$G$17").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ColumnWidth = 17.5
.Font.Bold = True
End With
For Each cl In Selection
cl.Value = x
cl.Interior.ColorIndex = x
x = x + 1
Next cl
Range("$D$1").Select
Selection = "COLORINDEX"
Selection.Font.Bold = True
Selection.HorizontalAlignment = xlCenter
Selection.ColumnWidth = 17.5
End Sub
lenze
lenze
06-13-2008, 11:37 AM
If you want to toggle between xlAutomatic, Red, And Green, try this
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Font.ColorIndex = 4 Then
Target.Font.ColorIndex = 3
Cancel = True
Exit Sub
End If
If Target.Font.ColorIndex = 3 Then
Target.Font.ColorIndex = xlAutomatic
Cancel = True
Exit Sub
End If
Target.Font.ColorIndex = 4
Cancel = True
End Sub
lenze
burtburt
06-13-2008, 01:05 PM
This will also work
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Font.ColorIndex = 4 Then
Target.Font.ColorIndex = 3
Cancel = True
ELSEIF Target.Font.ColorIndex = 3 Then
Target.Font.ColorIndex = xlAutomatic
Cancel = True
ELSEIF Target.Font.ColorIndex = xlAutomatic Then
Target.Font.ColorIndex = 4
Cancel = True
End If
End Sub
Bob Phillips
06-13-2008, 01:43 PM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Application.Dialogs(xlDialogPatterns).Show
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click
Bob Phillips
06-13-2008, 01:44 PM
See my post in your other thread.
lucas
06-13-2008, 03:43 PM
Joseph,
Why do you guys insist on taking the Bart Simpson approach to asking questions? Asking the same question in mutiple threads only turns people away from helping you. I have merged your identical thread questions and in the future please stick to one question/one thread.
How would you feel if you spent the time to research and respond to someone's question only to find out that they had posted the same question in a different thread and already had an answer.....you would probably not want to help them in the future would you?
Please be considerate of our contributors.....you are not the only one with a question and your question is darn sure not more important than everyone elses......
We like to run a friendly board here so we will insist that you behave and be courtious and gratious when you do receive the help you are here asking for.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.