enter image description hereI have VBA code by which I can show progress in excel cell by color with text value.
This code is working good in VBA . The function is called and Worksheet Name, Cell Roll column, percent and background color is passed as parameter. In this case background color red send in some condition otherwise white.
Same function I need in Python.
Public Sub barcolor(ByVal oSheet As Object, ByVal RowNo As Integer, ByVal ColNo As Integer, ByVal prct As Double, ByVal bg As Double)
Dim barValue As Double
Dim objColorStop As ColorStop
Dim myRange As Range
barValue = prct
If barValue = 0 Then
barValue = 0.000001
ElseIf barValue = 1 Then
barValue = 0.999998
End If
With oSheet.Range(oSheet.Cells(RowNo, ColNo), oSheet.Cells(RowNo, ColNo)).Interior
.Pattern = xlPatternLinearGradient
'Adjust Color Stops
'Clear Default Color Stops
.Gradient.ColorStops.Clear
With .Gradient.ColorStops.Add(0)
'.Color = RGB(97, 202, 74)
.Color = 6750054
End With
With .Gradient.ColorStops.Add(barValue)
.Color = 6750054
End With
'Add A Color Stop
With .Gradient.ColorStops.Add(barValue + 0.000001)
'.Color = RGB(255, 255, 255)
'.Color = 16777215
.Color = bg
End With
'Add Another Color Stop
With .Gradient.ColorStops.Add(1)
' .Color = RGB(255, 255, 255)
' .Color = 16777215
.Color = bg
End With
End With
End Sub
New contributor
Samiur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1