Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,075
- Office Version
- 2019
- Platform
- 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