Shufling Through Cells

MasterOfDisaster

Board Regular
Joined
Dec 19, 2007
Messages
70
I have the following code that goes through each cell of a range and if the cell is green it inputs a value into the cell:

Code:
    With Worksheets("PivotTable2")
        .PivotTables(1).PivotFields("ABC").CurrentPage = pvtitem.Name
    End With
    
    Worksheets("ABC" & pvtitem).Range("C6:AD30").Select
    For Each cl In Selection
        If cl.Interior.ColorIndex = 4 Then
            cl.Value = Worksheets("PivotTable2").Cells(cl.row + 1, cl.column + 1).Value
            cl.HorizontalAlignment = xlCenter
        End If
    Next cl

The problem is that some cells remain empty even if they shouldn't (I've verified this in several different ways). It's almost as if some cells of the range get skipped. Any ideas?

Thank you in advance!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
A thought:
Are you certain every row/col in the range being examined has a corresponding row/col in the pivot table and that the value in the pivot table is not blank?
 
Upvote 0

Forum statistics

Threads
1,215,775
Messages
6,126,828
Members
449,343
Latest member
DEWS2031

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top