Hi,
I have a Nested Loop that is taking a value from one workbook, which has a scpecific cell color....
So once that Outer Loop value is determined from the first book, It's going to scan inside a pivot table (Just down the intersecting column) to find that value from Book 1.
Once inside the pivot where in the nested part of the loop.
When running the Macro, I see that the interior cell color changes but reverts back to the normal format (inside the pivot) once the code has fully ran.
Here is a look at the code....
Sub Highlight()
'Outer Loop
Dim flag1 As Long
Dim counter1 As Long
flag1 = 0
counter1 = 3
Do While flag1 = 0
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Inner Loop Begins
Dim flag2
Dim Counter2
flag2 = 0
Counter2 = 6
Do While flag2 = 0
If Workbooks("Book1").Worksheets("Sheet1").Range("A" & counter1) = _
Workbooks("Book2").Worksheets("PivotSheet").Range("B" & Counter2) _
Then _
Workbooks("Book2").Worksheets("PivotSheet").Range("B" & Counter2).Interior.Color = _
Workbooks("Book1").Worksheets("Sheet1").Range("A" & counter1).Interior.Color
Counter2 = Counter2 + 1
If Workbooks("Book2").Worksheets("PivotSheet").Range("B" & Counter2) = "" Then _
flag2 = 1
Loop
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
counter1 = counter1 + 1
If Workbooks("Book1").Worksheets("Sheet1").Range("A" & counter1) = "" Then _
flag1 = 1
Loop
'******************************************************************************************************************
End Sub
Bookmarks