Bar Chart inverted color

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
how can i make the bars colored (red for negative numbers and green for positive numbers)

VBA Code:
Sub UpdateChartScrollbar(scrollbarValue As Long)
    Dim i As Long, MaxIndex As Long, LRow As Long
    Dim FName As String
    Dim Cht As Chart
    
    Set Wks = ActiveSheet
    Set Cht = Wks.ChartObjects("ch_Symbol").Chart
    
    LRow = Wks.Cells(Wks.Rows.Count, "BE").End(xlUp).row
    MaxIndex = (LRow - 7) \ 5
    ChartScrollbar.Max = MaxIndex
    
    For i = 0 To MaxIndex
        If scrollbarValue = i Then
            With Cht.SeriesCollection(1)
                .XValues = Wks.Range("BE" & (i * 5) + 7 & ":BE" & (i * 5) + 11)
                .values = Wks.Range("BG" & (i * 5) + 7 & ":BG" & (i * 5) + 11)
            End With
            Exit For
        End If
    Next i
    
    lbChtPgs.Caption = scrollbarValue + 1 & " of " & MaxIndex + 1

    With Cht.SeriesCollection(1)
        .ApplyDataLabels
        .DataLabels.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(255, 255, 255)
        .DataLabels.Position = xlLabelPositionInsideBase
    End With

    Wks.Shapes("ch_Symbol").Visible = True
    FName = Application.DefaultFilePath & "\TempChart.gif"
    Cht.Export Filename:=FName, FilterName:="GIF"
    Image8.Picture = LoadPicture(FName)
    Kill FName
    'Wks.Shapes("ch_Symbol").Visible = False
End Sub
 

Attachments

  • Untitled.png
    Untitled.png
    70.7 KB · Views: 8

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,216,138
Messages
6,129,099
Members
449,486
Latest member
malcolmlyle

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