Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Making a cell a color using color numbers

Is it possible to enter a color number (1-56 for example) and make that cell
the color in question?

I am guessing conditional formatting might be a way, but i think some code
may be needed.

Can anyone help?

Thanks,

Roger
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Making a cell a color using color numbers

Right click sheet tabview codecopy/paste this. You may want to restrict
the cells involved.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Roger on Excel" wrote in message
...
Is it possible to enter a color number (1-56 for example) and make that
cell
the color in question?

I am guessing conditional formatting might be a way, but i think some code
may be needed.

Can anyone help?

Thanks,

Roger


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Making a cell a color using color numbers

Hi Don,

Nice - it works well.

by the way, how would i restrict this to cell "b1"?

Thanks,

Roger



"Don Guillett" wrote:

Right click sheet tabview codecopy/paste this. You may want to restrict
the cells involved.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Roger on Excel" wrote in message
...
Is it possible to enter a color number (1-56 for example) and make that
cell
the color in question?

I am guessing conditional formatting might be a way, but i think some code
may be needed.

Can anyone help?

Thanks,

Roger



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Making a cell a color using color numbers

Excellent Don.

Thanks very much for this

Best regards, Roger



"Don Guillett" wrote:


Private Sub Worksheet_Change(ByVal Target As Range)

if target.address<"$B$1" then exit sub
'don't forget $ or " " and use CAPS for cell address

On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Roger on Excel" wrote in message
...
Hi Don,

Nice - it works well.

by the way, how would i restrict this to cell "b1"?

Thanks,

Roger



"Don Guillett" wrote:

Right click sheet tabview codecopy/paste this. You may want to restrict
the cells involved.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Roger on Excel" wrote in
message
...
Is it possible to enter a color number (1-56 for example) and make that
cell
the color in question?

I am guessing conditional formatting might be a way, but i think some
code
may be needed.

Can anyone help?

Thanks,

Roger






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Making a cell a color using color numbers

Roger,

I too am looking to do conditional formatting for 5 colors, or more. I saw
this which you posted. I have never done VBA.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub

I did find the following VBA but I made 2 substitutions: 1) an array instead
of a1:a10; 2) the numbers. PROBLEM: When I tested numbers, not all the
colors appears, no light green (#35). Second problem, when I opened the
file, I said enable macros which changed the colors but once inside the
sheet, changing the number in the array didn't change the colors.

I NEED ALL COLORS TO CHANGE AS A VALUE CHANGES IN THE TARGET CELL.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("T4:Z5")) Is Nothing Then
Select Case Target
Case Is <= 0.00000025
icolor = 4
Case 0.000001 To 0.0000002495
icolor = 35
Case 0.00001 To 0.0000995
icolor = 2
Case 0.0001 To 0.000995
icolor = 6
Case Is = 0.0001
icolor = 3
Case Else
'Whatever
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub

I'm on an important project!

THANK YOU,

Phyllis

"Don Guillett" wrote:

Right click sheet tabview codecopy/paste this. You may want to restrict
the cells involved.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Roger on Excel" wrote in message
...
Is it possible to enter a color number (1-56 for example) and make that
cell
the color in question?

I am guessing conditional formatting might be a way, but i think some code
may be needed.

Can anyone help?

Thanks,

Roger



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Making a cell a color using color numbers

It appears that you need to line up your 000000000000000 better

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"PA Simon" <PA
wrote in message
...
Roger,

I too am looking to do conditional formatting for 5 colors, or more. I
saw
this which you posted. I have never done VBA.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub

I did find the following VBA but I made 2 substitutions: 1) an array
instead
of a1:a10; 2) the numbers. PROBLEM: When I tested numbers, not all the
colors appears, no light green (#35). Second problem, when I opened the
file, I said enable macros which changed the colors but once inside the
sheet, changing the number in the array didn't change the colors.

I NEED ALL COLORS TO CHANGE AS A VALUE CHANGES IN THE TARGET CELL.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("T4:Z5")) Is Nothing Then
Select Case Target
Case Is <= 0.00000025
icolor = 4
Case 0.000001 To 0.0000002495
icolor = 35
Case 0.00001 To 0.0000995
icolor = 2
Case 0.0001 To 0.000995
icolor = 6
Case Is = 0.0001
icolor = 3
Case Else
'Whatever
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub

I'm on an important project!

THANK YOU,

Phyllis

"Don Guillett" wrote:

Right click sheet tabview codecopy/paste this. You may want to restrict
the cells involved.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If IsNumeric(Target) Then
Target.Interior.ColorIndex = Target.Value
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Roger on Excel" wrote in
message
...
Is it possible to enter a color number (1-56 for example) and make that
cell
the color in question?

I am guessing conditional formatting might be a way, but i think some
code
may be needed.

Can anyone help?

Thanks,

Roger




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
Making a cell a certain color for a value NDT_Steve Excel Worksheet Functions 3 January 22nd 09 11:25 AM
Making a Cell turn color based on results in another cell melaniem Excel Discussion (Misc queries) 6 January 11th 08 05:25 AM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
Code for making a cell chage color by dbl clicking, with either a Zan Dorris Excel Programming 1 February 13th 06 04:00 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM


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