Conditional Formatting of Charts by Value

Luin29

New Member
Joined
Oct 7, 2015
Messages
45
Hello everyone,

After six months of generating thousands of graphs, I am looking to automate the process. I have found a subroutine that, with some alterations, should be able to accomplish the final piece of the graph generation.

For this part of the graph generation, I would like to create a routine that will change the fill of markers in a chart based upon the values in a range. I have provide an example below:

Well IDDate SampledPCEChange
VW-21/25/2008ND<5.01
VW-26/20/20085.10
VW-29/23/20084.20
VW-211/5/2008ND<0.501

<tbody>
</tbody>

Each cell within the PCE column is evaluated in the next column to the right for text within the PCE cell and assigned is a value of 1 if text is present or 0 if not.

e.g. D2=IF(ISBLANK(C2),"",IF(ISTEXT(C2),1,0))"

The code I would like to generate would evaluate each cell within Change column and if true (Change column cell contains a 1) would then change the PCE marker in the adjacent cell fill's option change from "Solid" to "No fill".

Below are the few lines of code that I have attempted to alter for my purpose but have been unsuccessful so far:

Code:
Sub FillByValue()

  Dim rPatterns As Range
  Dim iPattern As Long
  Dim vPatterns As Variant
  Dim iPoint As Long
  Dim vValues As Variant
  Dim rValue As Range
  Dim i As Integer, j As Integer
lRow = Cells(Rows.Count, 1).End(xlUp).Row
itotalcolumns = ActiveSheet.Range("AB1").End(xlToLeft).Column
i = 3
Do While i <= itotalcolumns
    i = i + 1
ActiveSheet.ChartObjects("Chart 1").Activate
For j = 1 To ActiveChart.SeriesCollection.Count
  Set rPatterns = Range(Cells(2, i + 1), Cells(lRow, i + 1))
  vPatterns = rPatterns.Value
  With ActiveChart.SeriesCollection(j)
    vValues = .Values
    For iPoint = 1 To UBound(vValues)
      For iPattern = 1 To UBound(vPatterns)
'If D2=1 then change C2 marker fill's option to "No Fill"
        If vPatterns(iPattern).Value = 1 Then
            .Points(iPoint).Format.Fill.Visible = msoFalse
          Exit For
        End If
      Next
    Next
  End With
  i = i + 1
Next j
Loop
End Sub

Thank you very much for any help you can provide in advance. If needs be, I can provide the original code.




 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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