Hi All!
Would appreciate any help or advice anyone could pass on - would be highly appreciated! I have tried to attempt to solve this myself but I have no VBA knowledge and have not found anything on the internet.
What I'm trying to do is create a macro which takes cell (row) colour from a dataset and make the colours the same within a bar chart etc. I have found some coding but it takes the very first cell within a range and locks it - what I need is for the colour to change on certain rows (i.e. weekend data - yellow, weekday - blue).
The coding
I have found is as follows:
<colgroup><col><col><col span="3"></colgroup><tbody>
</tbody>
Would appreciate any help or advice anyone could pass on - would be highly appreciated! I have tried to attempt to solve this myself but I have no VBA knowledge and have not found anything on the internet.
What I'm trying to do is create a macro which takes cell (row) colour from a dataset and make the colours the same within a bar chart etc. I have found some coding but it takes the very first cell within a range and locks it - what I need is for the colour to change on certain rows (i.e. weekend data - yellow, weekday - blue).
The coding
I have found is as follows:
- Sub CellColorsToChart()
- Dim oChart As ChartObject
- Dim MySeries As Series
- Dim FormulaSplit As Variant
- Dim SourceRange As Range
- Dim SourceRangeColor As Long
-
- 'Loop through all charts in the active sheet
- For Each oChart In ActiveSheet.ChartObjects
-
- 'Loop through all series in the target chart
- For Each MySeries In oChart.Chart.SeriesCollection
-
- 'Get Source Data Range for the target series
- FormulaSplit = Split(MySeries.Formula, ",")
-
- 'Capture the first cell in the source range then trap the color
- Set SourceRange = Range(FormulaSplit(2)).Item(1)
- SourceRangeColor = SourceRange.Interior.Color
-
- On Error Resume Next
- 'Coloring for Excel 2003
- MySeries.Interior.Color = SourceRangeColor
- MySeries.Border.Color = SourceRangeColor
- MySeries.MarkerBackgroundColorIndex = SourceRangeColor
- MySeries.MarkerForegroundColorIndex = SourceRangeColor
-
- 'Coloring for Excel 2007 and 2010
- MySeries.MarkerBackgroundColor = SourceRangeColor
- MySeries.MarkerForegroundColor = SourceRangeColor
- MySeries.Format.Line.ForeColor.RGB = SourceRangeColor
- MySeries.Format.Line.BackColor.RGB = SourceRangeColor
- MySeries.Format.Fill.ForeColor.RGB = SourceRangeColor
-
- Next MySeries
- Next oChart
-
- End Sub
<colgroup><col><col><col></colgroup><tbody> </tbody> | |||||||||||||||||||||||||||||||||||||||||||
I need the weekends within the bar chart to be one colour (represented by whatever colour is in the cell, the weekdays by another colour. Hope this make some sense - thank you to anyone who could help me - huge thanks! | |||||||||||||||||||||||||||||||||||||||||||
<colgroup><col><col><col span="3"></colgroup><tbody>
</tbody>