View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Lars-Åke Aspelin[_2_] Lars-Åke Aspelin[_2_] is offline
external usenet poster
 
Posts: 913
Default 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