I'm new to VBA and would like to slowly teach myself, at least at a foundational level, with the help of mr Excel.
The following code sometimes works. It was kindly given to me by a response to a mr Excel thread sometime ago. I use it to make pie chart segments match the color of the label colors in the tables the pie's are generated from. Sometimes works sometimes does not. I have ensured that the cell referencing is correct:
Sub Brand1ColorByCategoryLabel()
Dim rPatterns As Range
Dim iCategory As Long
Dim vCategories As Variant
Dim rCategory As Range
Set rPatterns = ActiveSheet.Range("H18:H19")
With ActiveChart.SeriesCollection(1)
vCategories = .XValues
For iCategory = 1 To UBound(vCategories)
Set rCategory = rPatterns.Find(What:=vCategories(iCategory))
.Points(iCategory).Interior.ColorIndex = rCategory.Interior.ColorIndex
Next
End With
End Sub
Any help/ideas/solutions appreciated
Paul
The following code sometimes works. It was kindly given to me by a response to a mr Excel thread sometime ago. I use it to make pie chart segments match the color of the label colors in the tables the pie's are generated from. Sometimes works sometimes does not. I have ensured that the cell referencing is correct:
Sub Brand1ColorByCategoryLabel()
Dim rPatterns As Range
Dim iCategory As Long
Dim vCategories As Variant
Dim rCategory As Range
Set rPatterns = ActiveSheet.Range("H18:H19")
With ActiveChart.SeriesCollection(1)
vCategories = .XValues
For iCategory = 1 To UBound(vCategories)
Set rCategory = rPatterns.Find(What:=vCategories(iCategory))
.Points(iCategory).Interior.ColorIndex = rCategory.Interior.ColorIndex
Next
End With
End Sub
Any help/ideas/solutions appreciated
Paul