View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Clear Shaded Cells

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range

Set myRng = Selection 'ActiveSheet.usedrange

For Each myCell In myRng.Cells
If myCell.Interior.ColorIndex = 3 Then
myCell.ClearContents
End If
Next myCell

End Sub

Record a macro when you change the colorindex of a cell. Then use that in place
of the 3.

Select the range you want before you run the code. Or use the UsedRange if you
want.

Ed Davis wrote:

Thank you for the quick response.
I was looking to only clear the data not the shade as the shaded areas show
the user where the data goes.

"Dave Peterson" wrote in message
...
Or just get the entire range at once:

ActiveSheet.UsedRange.Interior.ColorIndex = xlNone

or even do all the cells:
activesheet.cells.Interior.ColorIndex = xlNone

Bernard Liengme wrote:

Sub tryme()
For Each mycell In ActiveSheet.UsedRange
mycell.Interior.ColorIndex = xlNone
Next mycell
End Sub

If you are new to VBA:
David McRitchie's site on "getting started" with VBA

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

Debra Dalgleish's "Adding Code to a Workbook"

http://www.contextures.com:80/xlvba01.html

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Ed Davis" wrote in message
...
Is there a way to clear all shaded cells in a worksheet using a macro?

I have received a lot of help from this news group.
Thank you very much.


--

Dave Peterson


--

Dave Peterson