ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro for shading (https://www.excelbanter.com/excel-worksheet-functions/189714-macro-shading.html)

Atomic

Macro for shading
 
I'd like to know wheater it is possible to have a cell shaded once an action
has been taken on it.

For example I have each cell in collums [A1] --- [D1] with a drop
list/validation. Once action has been taken I'd like for it to become shaded.
Is this possible?

Thank you in advance.


Dave

Macro for shading
 
Hi,
If you mean a specific action, ie a specific entry into a cell, then you can
do that with conditional formatting.
If you mean a more general action, like the selection of an option (but no
particular option) from the drop down menu, then you'd need a Change Event
macro.
Regards - Dave.

Lars-Åke Aspelin[_2_]

Macro for shading
 
On Mon, 2 Jun 2008 10:33:00 -0700, Atomic
wrote:

I'd like to know wheater it is possible to have a cell shaded once an action
has been taken on it.

For example I have each cell in collums [A1] --- [D1] with a drop
list/validation. Once action has been taken I'd like for it to become shaded.
Is this possible?

Thank you in advance.



Try if this macro does what you expect:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:D1")) Is Nothing Then
Target.Interior.ColorIndex = 15
End If
End Sub

Hope this helps / Lars-Åke


Atomic

Macro for shading
 
Thank you Lars-Ã…ke, that is exactly what I had in mind.

I noticed that the colour stayed as is when the entry was removed or
deleted. Is there a way to return it to "white" if say I enter a a "00" in
the cell or if the entry was deleted?

Thank you.


"Lars-Ã…ke Aspelin" wrote:

On Mon, 2 Jun 2008 10:33:00 -0700, Atomic
wrote:

I'd like to know wheater it is possible to have a cell shaded once an action
has been taken on it.

For example I have each cell in collums [A1] --- [D1] with a drop
list/validation. Once action has been taken I'd like for it to become shaded.
Is this possible?

Thank you in advance.



Try if this macro does what you expect:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:D1")) Is Nothing Then
Target.Interior.ColorIndex = 15
End If
End Sub

Hope this helps / Lars-Ã…ke


Lars-Åke Aspelin[_2_]

Macro for shading
 
The following sets the background color to white if the value entered
is equal to 0.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:D1")) Is Nothing Then
Target.Interior.ColorIndex = 15
If Target.Value = 0 Then
Target.Interior.ColorIndex = 0
End If
End If
End Sub

Hope this helps / Lars-Åke


On Mon, 2 Jun 2008 13:30:02 -0700, Atomic
wrote:

Thank you Lars-Åke, that is exactly what I had in mind.

I noticed that the colour stayed as is when the entry was removed or
deleted. Is there a way to return it to "white" if say I enter a a "00" in
the cell or if the entry was deleted?

Thank you.


"Lars-Åke Aspelin" wrote:

On Mon, 2 Jun 2008 10:33:00 -0700, Atomic
wrote:

I'd like to know wheater it is possible to have a cell shaded once an action
has been taken on it.

For example I have each cell in collums [A1] --- [D1] with a drop
list/validation. Once action has been taken I'd like for it to become shaded.
Is this possible?

Thank you in advance.



Try if this macro does what you expect:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:D1")) Is Nothing Then
Target.Interior.ColorIndex = 15
End If
End Sub

Hope this helps / Lars-Åke



Atomic

Macro for shading
 
Thank you Lars-Ã…ke, again. I'll study this formula now and try some new things.
really appreciate it. ^_^)v

"Lars-Ã…ke Aspelin" wrote:

The following sets the background color to white if the value entered
is equal to 0.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:D1")) Is Nothing Then
Target.Interior.ColorIndex = 15
If Target.Value = 0 Then
Target.Interior.ColorIndex = 0
End If
End If
End Sub

Hope this helps / Lars-Ã…ke


On Mon, 2 Jun 2008 13:30:02 -0700, Atomic
wrote:

Thank you Lars-Ã…ke, that is exactly what I had in mind.

I noticed that the colour stayed as is when the entry was removed or
deleted. Is there a way to return it to "white" if say I enter a a "00" in
the cell or if the entry was deleted?

Thank you.


"Lars-Ã…ke Aspelin" wrote:

On Mon, 2 Jun 2008 10:33:00 -0700, Atomic
wrote:

I'd like to know wheater it is possible to have a cell shaded once an action
has been taken on it.

For example I have each cell in collums [A1] --- [D1] with a drop
list/validation. Once action has been taken I'd like for it to become shaded.
Is this possible?

Thank you in advance.


Try if this macro does what you expect:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:D1")) Is Nothing Then
Target.Interior.ColorIndex = 15
End If
End Sub

Hope this helps / Lars-Ã…ke





All times are GMT +1. The time now is 11:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com