Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change back round color of a cell w/VB

I would like to change the color of cell (1,1) to red by
placing a 1 in in cell (1,2) I can't seem to figur it out
please help.

Thank you

Sean
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Change back round color of a cell w/VB

You can use the worksheet change event, like this:

'If the value in A2 = 1, change cell color of A1 to Red
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("A2") Then
If Range("A2").Value = 1 Then
Range("A1").Interior.ColorIndex = 3
Else
Range("A1").Interior.ColorIndex = xlNone
End If
End If
End Sub

tod
-----Original Message-----
I would like to change the color of cell (1,1) to red

by
placing a 1 in in cell (1,2) I can't seem to figur it

out
please help.

Thank you

Sean
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Change back round color of a cell w/VB

I tried to cut and paste the code but it did not work.
any other sugestions??????

Thanks,

Sean

"Tod" wrote:

You can use the worksheet change event, like this:

'If the value in A2 = 1, change cell color of A1 to Red
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("A2") Then
If Range("A2").Value = 1 Then
Range("A1").Interior.ColorIndex = 3
Else
Range("A1").Interior.ColorIndex = xlNone
End If
End If
End Sub

tod
-----Original Message-----
I would like to change the color of cell (1,1) to red

by
placing a 1 in in cell (1,2) I can't seem to figur it

out
please help.

Thank you

Sean
.


  #4   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Change back round color of a cell w/VB

Make sure to cut and paste the code into the ThisWorkbook
module and not the worksheet module.

-----Original Message-----
I tried to cut and paste the code but it did not work.
any other sugestions??????

Thanks,

Sean

"Tod" wrote:

You can use the worksheet change event, like this:

'If the value in A2 = 1, change cell color of A1 to Red
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("A2") Then
If Range("A2").Value = 1 Then
Range("A1").Interior.ColorIndex = 3
Else
Range("A1").Interior.ColorIndex = xlNone
End If
End If
End Sub

tod
-----Original Message-----
I would like to change the color of cell (1,1) to

red
by
placing a 1 in in cell (1,2) I can't seem to figur

it
out
please help.

Thank you

Sean
.


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Change back round color of a cell w/VB

is there a way to write the code where it will work several cells? I am
using this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("F2") Then
If Range("F2").Value = 1 Then
Range("A2").Interior.ColorIndex = 6
ElseIf Range("F2").Value = 2 Then
Range("A2").Interior.ColorIndex = 7
ElseIf Range("F2").Value = 3 Then
Range("A2").Interior.ColorIndex = 8
Else
Range("A2").Interior.ColorIndex = x1none
End If
End If
End Sub

what I would like to do is have this for f2:f100 if you put a 1,2,3 in one
of those cells it will change the color of the cell in the A colum.

Thank you for all the help!

Sean
"Tod" wrote:

Make sure to cut and paste the code into the ThisWorkbook
module and not the worksheet module.

-----Original Message-----
I tried to cut and paste the code but it did not work.
any other sugestions??????

Thanks,

Sean

"Tod" wrote:

You can use the worksheet change event, like this:

'If the value in A2 = 1, change cell color of A1 to Red
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("A2") Then
If Range("A2").Value = 1 Then
Range("A1").Interior.ColorIndex = 3
Else
Range("A1").Interior.ColorIndex = xlNone
End If
End If
End Sub

tod
-----Original Message-----
I would like to change the color of cell (1,1) to

red
by
placing a 1 in in cell (1,2) I can't seem to figur

it
out
please help.

Thank you

Sean
.


.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Change back round color of a cell w/VB

Hi Sean,

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rw, Col
Rw = Target.Row: Col = Target.Column
If Rw < 2 Or Rw 100 Then Exit Sub
If Col < 6 Then Exit Sub
Select Case Target.Value
Case Is = 1
Cells(Rw, 1).Interior.ColorIndex = 6
Case Is = 2
Cells(Rw, 1).Interior.ColorIndex = 7
Case Is = 3
Cells(Rw, 1).Interior.ColorIndex = 8
Case Else
Cells(Rw, 1).Interior.ColorIndex = xlNone
End Select
End Sub

Regards,
Don

"Sean" wrote in message
...
is there a way to write the code where it will work several cells? I am
using this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("F2") Then
If Range("F2").Value = 1 Then
Range("A2").Interior.ColorIndex = 6
ElseIf Range("F2").Value = 2 Then
Range("A2").Interior.ColorIndex = 7
ElseIf Range("F2").Value = 3 Then
Range("A2").Interior.ColorIndex = 8
Else
Range("A2").Interior.ColorIndex = x1none
End If
End If
End Sub

what I would like to do is have this for f2:f100 if you put a 1,2,3 in one
of those cells it will change the color of the cell in the A colum.

Thank you for all the help!

Sean
"Tod" wrote:

Make sure to cut and paste the code into the ThisWorkbook
module and not the worksheet module.

-----Original Message-----
I tried to cut and paste the code but it did not work.
any other sugestions??????

Thanks,

Sean

"Tod" wrote:

You can use the worksheet change event, like this:

'If the value in A2 = 1, change cell color of A1 to Red
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("A2") Then
If Range("A2").Value = 1 Then
Range("A1").Interior.ColorIndex = 3
Else
Range("A1").Interior.ColorIndex = xlNone
End If
End If
End Sub

tod
-----Original Message-----
I would like to change the color of cell (1,1) to

red
by
placing a 1 in in cell (1,2) I can't seem to figur

it
out
please help.

Thank you

Sean
.


.




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
Why font color change back to black when I select a different cell Cody Excel Worksheet Functions 1 March 2nd 10 07:35 AM
formula to change back ground cell color according to a value JP Excel Discussion (Misc queries) 1 May 12th 08 03:02 AM
How do I get back the cell color display on screen. SEI PHIL Excel Discussion (Misc queries) 3 March 6th 07 02:21 AM
back ground color doesn't work in cell. Soother Excel Worksheet Functions 1 October 7th 05 02:14 AM
Change cell back color on click Dave Peterson Excel Discussion (Misc queries) 0 January 24th 05 10:50 PM


All times are GMT +1. The time now is 10:17 AM.

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

About Us

"It's about Microsoft Excel"