Clint,
Add "Option Explicit" as the first line in your module then
give this a try...
'--
Sub standardCanKill()
Dim c As Range
Dim MyRange As Range
Dim arrRng() As String
Dim yellowCells As Long
Dim N As Long
Dim M As Long
Set MyRange = Range("A1:D20")
ReDim arrRng(1 To MyRange.Count)
For Each c In MyRange
If c.Interior.ColorIndex = 6 Then
If c.MergeCells Then
N = N + 1
For M = 1 To N
If c.MergeArea.Address = arrRng(M) Then
Exit For
End If
Next
If M N Then
yellowCells = yellowCells + 1
arrRng(N) = c.MergeArea.Address
End If
Else
yellowCells = yellowCells + 1
End If
End If
Next
MsgBox yellowCells
Set c = Nothing
Set MyRange = Nothing
End Sub
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
"Whois Clinton"
wrote in message
I am using 2003 and counting colored blank cells. The range is several rows
with some rows containing 4 column cells (ie A1, B1, C1, D1) and other rows
with only 2 column cells having merged A1 and B1 into one cell with C1 and D1
into a second merged cell.
I need the merged cells to only count as one. Currently they count as 2
when I run the following:
Sub standard()
Set myrange = Range("A1:D20")
For Each c In myrange
If c.Interior.ColorIndex = 6 Then
yellowcells = yellowcells + 1
End If
Next
MsgBox yellowcells
End Sub
I am not an expert macro writer so I hope this makes sense :J
Thanks in advance for any help.
Clint