Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default how do I change color of "active" cell to differentiate from rest

I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default how do I change color of "active" cell to differentiate from rest

Try this tiny worksheet event macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200782


"devildog97" wrote:

I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 158
Default how do I change color of "active" cell to differentiate from rest

That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex
Target.Interior.ColorIndex = 6
Cells.Interior.ColorIndex = i
Else
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End If
End Sub


Steven

On Apr 29, 2:54*pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200782



"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color.- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default how do I change color of "active" cell to differentiate from r

It is a bit more complex. Whenever we select a cell, before making any
changes, we must first "remember" the cell's address and interior color in
global static variables. That way when we select another cell, we will have
enough information to restore the original's color.
--
Gary''s Student - gsnu200782


" wrote:

That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex
Target.Interior.ColorIndex = 6
Cells.Interior.ColorIndex = i
Else
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End If
End Sub


Steven

On Apr 29, 2:54 pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200782



"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color.- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 158
Default how do I change color of "active" cell to differentiate from r

I tried to capture ("remember") the interior colour using the variable
i in my formula

If If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex

But that doesn't quite do it. So, I need to capture the cell address
Let x = Selection.Range


Still not there. Perhaps the "Let" is not the correct route. I've seen
Dim used in a similar manner, but I don't know what it means.

Thanks for your help!


S

On Apr 29, 3:51*pm, Gary''s Student
wrote:
It is a bit more complex. *Whenever we select a cell, before making any
changes, we must first "remember" the cell's address and interior color in
global static variables. *That way when we select another cell, we will have
enough information to restore the original's color.
--
Gary''s Student - gsnu200782



" wrote:
That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
* * Let i = Target.Interior.ColorIndex
* * Target.Interior.ColorIndex = 6
* * Cells.Interior.ColorIndex = i
Else
* * Cells.Interior.ColorIndex = xlNone
* * Target.Interior.ColorIndex = 6
End If
End Sub


Steven


On Apr 29, 2:54 pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub


Because it is worksheet code, it is very easy to install and use:


1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window


If you save the workbook, the macro will be saved with it.


To remove the macro:


1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window


To learn more about macros in general, see:


http://www.mvps.org/dmcritchie/excel/getstarted.htm


To learn more about Event Macros (worksheet code), see:


http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200782


"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color..- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default how do I change color of "active" cell to differentiate from r

Check this post for an update tomorrow.
--
Gary''s Student - gsnu200782


" wrote:

I tried to capture ("remember") the interior colour using the variable
i in my formula

If If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex

But that doesn't quite do it. So, I need to capture the cell address
Let x = Selection.Range


Still not there. Perhaps the "Let" is not the correct route. I've seen
Dim used in a similar manner, but I don't know what it means.

Thanks for your help!


S

On Apr 29, 3:51 pm, Gary''s Student
wrote:
It is a bit more complex. Whenever we select a cell, before making any
changes, we must first "remember" the cell's address and interior color in
global static variables. That way when we select another cell, we will have
enough information to restore the original's color.
--
Gary''s Student - gsnu200782



" wrote:
That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex
Target.Interior.ColorIndex = 6
Cells.Interior.ColorIndex = i
Else
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End If
End Sub


Steven


On Apr 29, 2:54 pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub


Because it is worksheet code, it is very easy to install and use:


1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window


If you save the workbook, the macro will be saved with it.


To remove the macro:


1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window


To learn more about macros in general, see:


http://www.mvps.org/dmcritchie/excel/getstarted.htm


To learn more about Event Macros (worksheet code), see:


http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200782


"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color..- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default how do I change color of "active" cell to differentiate from r

Check this out:

Public OldRange As Range
Public OldColor As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'''''''''''''''''''''''''''''''''''''''
' restore the previous clicked cell
'''''''''''''''''''''''''''''''''''''''
If OldRange Is Nothing Then
Else
OldRange.Interior.ColorIndex = OldColor
End If
'''''''''''''''''''''''''''''''''''''
' next remember the old color
'''''''''''''''''''''''''''''''''''''
Set OldRange = Target
OldColor = Target.Interior.ColorIndex
''''''''''''''''''''''''''''''''''''''
' last set the display color
''''''''''''''''''''''''''''''''''''''
Target.Interior.ColorIndex = 6
End Sub

Note that OldRange and OldColor are declared BEFORE the macro starts.
--
Gary''s Student - gsnu200782


" wrote:

I tried to capture ("remember") the interior colour using the variable
i in my formula

If If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex

But that doesn't quite do it. So, I need to capture the cell address
Let x = Selection.Range


Still not there. Perhaps the "Let" is not the correct route. I've seen
Dim used in a similar manner, but I don't know what it means.

Thanks for your help!


S

On Apr 29, 3:51 pm, Gary''s Student
wrote:
It is a bit more complex. Whenever we select a cell, before making any
changes, we must first "remember" the cell's address and interior color in
global static variables. That way when we select another cell, we will have
enough information to restore the original's color.
--
Gary''s Student - gsnu200782



" wrote:
That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex
Target.Interior.ColorIndex = 6
Cells.Interior.ColorIndex = i
Else
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End If
End Sub


Steven


On Apr 29, 2:54 pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub


Because it is worksheet code, it is very easy to install and use:


1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window


If you save the workbook, the macro will be saved with it.


To remove the macro:


1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window


To learn more about macros in general, see:


http://www.mvps.org/dmcritchie/excel/getstarted.htm


To learn more about Event Macros (worksheet code), see:


http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200782


"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color..- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 158
Default how do I change color of "active" cell to differentiate from r

Of course! That makes sense, since the macro takes effect as soon as
you click in a cell. Though, I admit I am still having trouble
wrapping my mind around the macro, but that is just all part of the
learning process.

One final issue, (I am really not trying to complicate things, they
just come up as I work on things) when I select a full column, or a
range of cells where there is a variety of different interior colours,
I get a runtime error '94' Invalid use of Null. I understand why it
happens, but is there a way to prevent it?

Thanks for all your time!


S

On Apr 29, 7:19*pm, Gary''s Student
wrote:
Check this out:

Public OldRange As Range
Public OldColor As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'''''''''''''''''''''''''''''''''''''''
' * restore the previous clicked cell
'''''''''''''''''''''''''''''''''''''''
If OldRange Is Nothing Then
Else
* * OldRange.Interior.ColorIndex = OldColor
End If
'''''''''''''''''''''''''''''''''''''
' * next remember the old color
'''''''''''''''''''''''''''''''''''''
Set OldRange = Target
OldColor = Target.Interior.ColorIndex
''''''''''''''''''''''''''''''''''''''
' * last set the display color
''''''''''''''''''''''''''''''''''''''
Target.Interior.ColorIndex = 6
End Sub

Note that OldRange and OldColor are declared BEFORE the macro starts.
--
Gary''s Student - gsnu200782



" wrote:
I tried to capture ("remember") the interior colour using the variable
i in my formula


If If Target.Interior.ColorIndex 0 Then
* * Let i = Target.Interior.ColorIndex


But that doesn't quite do it. So, I need to capture the cell address
Let x = Selection.Range


Still not there. Perhaps the "Let" is not the correct route. I've seen
Dim used in a similar manner, but I don't know what it means.


Thanks for your help!


S


On Apr 29, 3:51 pm, Gary''s Student
wrote:
It is a bit more complex. *Whenever we select a cell, before making any
changes, we must first "remember" the cell's address and interior color in
global static variables. *That way when we select another cell, we will have
enough information to restore the original's color.
--
Gary''s Student - gsnu200782


" wrote:
That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
* * Let i = Target.Interior.ColorIndex
* * Target.Interior.ColorIndex = 6
* * Cells.Interior.ColorIndex = i
Else
* * Cells.Interior.ColorIndex = xlNone
* * Target.Interior.ColorIndex = 6
End If
End Sub


Steven


On Apr 29, 2:54 pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub


Because it is worksheet code, it is very easy to install and use:


1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window


If you save the workbook, the macro will be saved with it.


To remove the macro:


1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window


To learn more about macros in general, see:


http://www.mvps.org/dmcritchie/excel/getstarted.htm


To learn more about Event Macros (worksheet code), see:


http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200782


"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color..- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default how do I change color of "active" cell to differentiate from r

Your final issue is completely logical. I should have considered it befo

Public OldRange As Range
Public OldColor As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Count 1 Then Exit Sub
'''''''''''''''''''''''''''''''''''''''
' restore the previous clicked cell
'''''''''''''''''''''''''''''''''''''''
If OldRange Is Nothing Then
Else
OldRange.Interior.ColorIndex = OldColor
End If
'''''''''''''''''''''''''''''''''''''
' next remember the old color
'''''''''''''''''''''''''''''''''''''
Set OldRange = Target
OldColor = Target.Interior.ColorIndex
''''''''''''''''''''''''''''''''''''''
' last set the display color
''''''''''''''''''''''''''''''''''''''
Target.Interior.ColorIndex = 6
End Sub


--
Gary''s Student - gsnu200782


" wrote:

Of course! That makes sense, since the macro takes effect as soon as
you click in a cell. Though, I admit I am still having trouble
wrapping my mind around the macro, but that is just all part of the
learning process.

One final issue, (I am really not trying to complicate things, they
just come up as I work on things) when I select a full column, or a
range of cells where there is a variety of different interior colours,
I get a runtime error '94' Invalid use of Null. I understand why it
happens, but is there a way to prevent it?

Thanks for all your time!


S

On Apr 29, 7:19 pm, Gary''s Student
wrote:
Check this out:

Public OldRange As Range
Public OldColor As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'''''''''''''''''''''''''''''''''''''''
' restore the previous clicked cell
'''''''''''''''''''''''''''''''''''''''
If OldRange Is Nothing Then
Else
OldRange.Interior.ColorIndex = OldColor
End If
'''''''''''''''''''''''''''''''''''''
' next remember the old color
'''''''''''''''''''''''''''''''''''''
Set OldRange = Target
OldColor = Target.Interior.ColorIndex
''''''''''''''''''''''''''''''''''''''
' last set the display color
''''''''''''''''''''''''''''''''''''''
Target.Interior.ColorIndex = 6
End Sub

Note that OldRange and OldColor are declared BEFORE the macro starts.
--
Gary''s Student - gsnu200782



" wrote:
I tried to capture ("remember") the interior colour using the variable
i in my formula


If If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex


But that doesn't quite do it. So, I need to capture the cell address
Let x = Selection.Range


Still not there. Perhaps the "Let" is not the correct route. I've seen
Dim used in a similar manner, but I don't know what it means.


Thanks for your help!


S


On Apr 29, 3:51 pm, Gary''s Student
wrote:
It is a bit more complex. Whenever we select a cell, before making any
changes, we must first "remember" the cell's address and interior color in
global static variables. That way when we select another cell, we will have
enough information to restore the original's color.
--
Gary''s Student - gsnu200782


" wrote:
That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
Let i = Target.Interior.ColorIndex
Target.Interior.ColorIndex = 6
Cells.Interior.ColorIndex = i
Else
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End If
End Sub


Steven


On Apr 29, 2:54 pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub


Because it is worksheet code, it is very easy to install and use:


1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window


If you save the workbook, the macro will be saved with it.


To remove the macro:


1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window


To learn more about macros in general, see:


http://www.mvps.org/dmcritchie/excel/getstarted.htm


To learn more about Event Macros (worksheet code), see:


http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200782


"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color..- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 158
Default how do I change color of "active" cell to differentiate from r

Ah, just restrict the number of cells the macro works on to 1.

Thank you, a great exercise in learning VB basics.

On Apr 30, 3:54*pm, Gary''s Student
wrote:
Your final issue is completely logical. *I should have considered it befo

Public OldRange As Range
Public OldColor As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Count 1 Then Exit Sub
'''''''''''''''''''''''''''''''''''''''
' restore the previous clicked cell
'''''''''''''''''''''''''''''''''''''''
If OldRange Is Nothing Then
Else
OldRange.Interior.ColorIndex = OldColor
End If
'''''''''''''''''''''''''''''''''''''
' next remember the old color
'''''''''''''''''''''''''''''''''''''
Set OldRange = Target
OldColor = Target.Interior.ColorIndex
''''''''''''''''''''''''''''''''''''''
' last set the display color
''''''''''''''''''''''''''''''''''''''
Target.Interior.ColorIndex = 6
End Sub

--
Gary''s Student - gsnu200782



" wrote:
Of course! That makes sense, since the macro takes effect as soon as
you click in a cell. Though, I admit I am still having trouble
wrapping my mind around the macro, but that is just all part of the
learning process.


One final issue, (I am really not trying to complicate things, they
just come up as I work on things) when I select a full column, or a
range of cells where there is a variety of different interior colours,
I get a runtime error '94' Invalid use of Null. I understand why it
happens, but is there a way to prevent it?


Thanks for all your time!


S


On Apr 29, 7:19 pm, Gary''s Student
wrote:
Check this out:


Public OldRange As Range
Public OldColor As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'''''''''''''''''''''''''''''''''''''''
' * restore the previous clicked cell
'''''''''''''''''''''''''''''''''''''''
If OldRange Is Nothing Then
Else
* * OldRange.Interior.ColorIndex = OldColor
End If
'''''''''''''''''''''''''''''''''''''
' * next remember the old color
'''''''''''''''''''''''''''''''''''''
Set OldRange = Target
OldColor = Target.Interior.ColorIndex
''''''''''''''''''''''''''''''''''''''
' * last set the display color
''''''''''''''''''''''''''''''''''''''
Target.Interior.ColorIndex = 6
End Sub


Note that OldRange and OldColor are declared BEFORE the macro starts.
--
Gary''s Student - gsnu200782


" wrote:
I tried to capture ("remember") the interior colour using the variable
i in my formula


If If Target.Interior.ColorIndex 0 Then
* * Let i = Target.Interior.ColorIndex


But that doesn't quite do it. So, I need to capture the cell address
Let x = Selection.Range


Still not there. Perhaps the "Let" is not the correct route. I've seen
Dim used in a similar manner, but I don't know what it means.


Thanks for your help!


S


On Apr 29, 3:51 pm, Gary''s Student
wrote:
It is a bit more complex. *Whenever we select a cell, before making any
changes, we must first "remember" the cell's address and interior color in
global static variables. *That way when we select another cell, we will have
enough information to restore the original's color.
--
Gary''s Student - gsnu200782


" wrote:
That's a cool like formula, I tried it on a worksheet that I am toying
with, but when I selected a cell that had existing formatting, it
cleared it back to white when I clicked away. Is it possible to return
it to the original colour? I've made a brief stab at it, but I'm still
pretty green with code.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Dim i As Target.Interior.ColorIndex
If Target.Interior.ColorIndex 0 Then
* * Let i = Target.Interior.ColorIndex
* * Target.Interior.ColorIndex = 6
* * Cells.Interior.ColorIndex = i
Else
* * Cells.Interior.ColorIndex = xlNone
* * Target.Interior.ColorIndex = 6
End If
End Sub


Steven


On Apr 29, 2:54 pm, Gary''s Student
wrote:
Try this tiny worksheet event macro:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.Interior.ColorIndex = 6
End Sub


Because it is worksheet code, it is very easy to install and use:


1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window


If you save the workbook, the macro will be saved with it.


To remove the macro:


1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window


To learn more about macros in general, see:


http://www.mvps.org/dmcritchie/excel/getstarted.htm


To learn more about Event Macros (worksheet code), see:


http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200782


"devildog97" wrote:
I want the cell I am working in to be highlighted in a color other then
white. How to I format it as so. Example.... wherever I click on the
worksheet, I want that single cell to be highligted to uniform color..- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


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
How do I change the fill color of a cell using an "IF" function donschap Excel Worksheet Functions 6 March 9th 10 03:48 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
change background color of a cell with an "IF" command? Lee Excel Worksheet Functions 1 June 30th 07 07:41 PM
How to change text color in a cell "comment" in Office 2007? conductor Excel Worksheet Functions 1 June 2nd 07 02:50 AM
"outline active cell differently than other cells" terri Excel Discussion (Misc queries) 1 January 25th 06 08:26 PM


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