Thread: Macro
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_5_] Gary Brown[_5_] is offline
external usenet poster
 
Posts: 236
Default Macro

Yes,
Sub test()
Dim cell As Range
For Each cell In Selection
If cell.Interior.ColorIndex = 6 Then
cell.ClearContents
End If
Next cell
End Sub

6 is bright yellow
36 is light yellow

or using Range Names...
Sub test()
Dim cell As Range
For Each cell In Range("TEST")
If cell.Interior.ColorIndex = 6 Then
cell.ClearContents
End If
Next cell
End Sub

HTH,
Gary Brown


"Paul H" wrote:

Can a macro be written that would clear the contents from all yellow cells?

"Jim Thomlinson" wrote:

Nope. The Macro is what it is... You need to change the macro to dynamically
determine what it needs to do, not clear the contenst of a "Hard Coded" cell.
I would need to see the code and get a few more details to help you...

"Paul H" wrote:

I have created a simple macro that when used will clear out the contents of a
certain cells. If I insert an additional row the macro does not adjust and
the macro needs to be edited. Is there a way to have the macro adjust
automatically when a row is insurted?