VBA issues with .ColorIndex on graphs

mushu888

New Member
Joined
Jul 16, 2012
Messages
1
I have this chart maker that makes bar charts structured with multiple series (upwards of 100) and then colors in the bars based on other criterion.

I'm not going to post the entirety of my code because it's just a snippet that seems not to work.

By not work, it's not that there are bugs, it's just that the desired effect is not achieved.

Onto the issue/snippet:

Code:
Dim c as Long, cT as Long

cT = 88

For c = 1 To cT
    ActiveChart.SeriesCollection(c).Select
    With Selection.Interior
        .ColorIndex = 15
        .Pattern = xlSolid
    End With
Next

So the code works for until c=57, at which point it stops executing .ColorIndex = 15 despite F8 going through ok (no bugs). The .Pattern = xlSolid code continues to work for c>57 but .ColorIndex stays the same and does not get changed to 15.

To make matters even more confusing, my conditionals nested with these loops seem to be working just fine.
Code:
            If Workbooks("StockPickingExercise2012 1H.xls").Sheets("Temp").Cells(c2, 6).Value = "Long" Then
                ActiveChart.SeriesCollection(c).Select
                With Selection.Interior
                    .ColorIndex = 4
                    .Pattern = xlSolid
                End With

The largest selections I have to deal with are ~150, so I have already tried breaking up the loop into smaller chunks (c = 1 to 56 and c = 56 to 88) but this doesn't work either.

Code is looking disobedient. Suggestions?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,777
Messages
6,126,835
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