Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Loop through worksheets & empty cells based on color

How can I loop through every cell in every worksheet and if the cell color is
Yellow or Light Yellow reset the cell value depending on its type to "" or 0 ?

I have barely started the code and more questions are coming then answers.

Private Sub cmdClearAllDataCells_Click()
Dim ws As Worksheet
Dim oCell As Range
If MsgBox("Clear ALL quote data?", vbYesNo + vbQuestion) = vbNo _
Then Exit Sub
For Each ws In ActiveWorkbook.Worksheets
For Each oCell In Selection
'
Next
Next
End If
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Loop through worksheets & empty cells based on color


For each oCell in ws.UsedRange
If oCell.Interior.ColorIndex < xlColorIndexNone Then

--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Eugene_Elder"
wrote in message
How can I loop through every cell in every worksheet and if the cell color is
Yellow or Light Yellow reset the cell value depending on its type to "" or 0 ?

I have barely started the code and more questions are coming then answers.

Private Sub cmdClearAllDataCells_Click()
Dim ws As Worksheet
Dim oCell As Range
If MsgBox("Clear ALL quote data?", vbYesNo + vbQuestion) = vbNo _
Then Exit Sub
For Each ws In ActiveWorkbook.Worksheets
For Each oCell In Selection
'
Next
Next
End If
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Loop through worksheets & empty cells based on color

one way:

Public Sub ResetYellow()
Dim ws As Worksheet
Dim rCell As Range
Dim nResult As Long
Dim nColorIndex As Long

nResult = MsgBox(prompt:="Clear ALL quote data?", _
Title:="Clear Data", _
Buttons:=vbYesNo + vbQuestion)
If nResult = vbYes Then
For Each ws In ActiveWorkbook.Worksheets
For Each rCell In ws.UsedRange
With rCell
nColorIndex = .Interior.ColorIndex
If nColorIndex = 6 Or nColorIndex = 36 Then
If IsNumeric(.Value) Then
.Value = 0
Else
.Value = ""
End If
End If
End With
Next rCell
Next ws
End If
End Sub

This assumes your colors are the default palette.

In article ,
Eugene_Elder wrote:

How can I loop through every cell in every worksheet and if the cell color is
Yellow or Light Yellow reset the cell value depending on its type to "" or 0 ?

I have barely started the code and more questions are coming then answers.

Private Sub cmdClearAllDataCells_Click()
Dim ws As Worksheet
Dim oCell As Range
If MsgBox("Clear ALL quote data?", vbYesNo + vbQuestion) = vbNo _
Then Exit Sub
For Each ws In ActiveWorkbook.Worksheets
For Each oCell In Selection
'
Next
Next
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Loop through worksheets & empty cells based on color

If the ranges to clean up don't change, you may want to use Insert|Name|define
and create a couple of range names that you can use:

with worksheets("sheetnamehere")
.range("ResetToZero").value = 0
.range("ResetToEmpty").clearcontents
end with





Eugene_Elder wrote:

How can I loop through every cell in every worksheet and if the cell color is
Yellow or Light Yellow reset the cell value depending on its type to "" or 0 ?

I have barely started the code and more questions are coming then answers.

Private Sub cmdClearAllDataCells_Click()
Dim ws As Worksheet
Dim oCell As Range
If MsgBox("Clear ALL quote data?", vbYesNo + vbQuestion) = vbNo _
Then Exit Sub
For Each ws In ActiveWorkbook.Worksheets
For Each oCell In Selection
'
Next
Next
End If
End Sub


--

Dave Peterson
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
Trying to loop through all shapes on multiple worksheets and change color [email protected] Excel Programming 1 April 14th 06 12:25 AM
change fill color of a range of cells based on color of a cell? DarMelNel Excel Programming 0 March 2nd 06 06:35 PM
Loop criteria based on cell value and color Jim at Eagle Excel Programming 2 January 27th 06 12:56 AM
Empty cells in For Loop Linking to specific cells in pivot table Excel Programming 2 May 16th 05 07:25 PM
Loop to change cell color based on found value? gaba Excel Programming 3 November 3rd 04 02:33 PM


All times are GMT +1. The time now is 07:00 PM.

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"