VBA Code:
' VBA Code to Create a Progress Bar in Excel
Sub CreateProgressBar()
Dim ws As Worksheet
Dim rng As Range
Dim progressBar As Shape
Dim progressCell As Range
Dim progressValue As Double
' Set the worksheet and range for the progress bar
Set ws = ThisWorkbook.Worksheets("Sheet1") ' Replace with the name of your worksheet
Set rng = ws.Range("A1") ' Replace with the cell where you want to position the progress bar
' Set the range for the progress value
Set progressCell = ws.Range("B1") ' Replace with the cell containing the progress value
' Get the progress value from the cell
progressValue = progressCell.Value
' Create the progress bar shape
Set progressBar = ws.Shapes.AddShape(msoShapeRectangle, rng.Left, rng.Top, rng.Width * progressValue, rng.Height)
' Customize the progress bar appearance
With progressBar
.Fill.ForeColor.RGB = RGB(0, 255, 0) ' Green color
.Line.Visible = False
End With
' Adjust the shape properties to match the progress value
With rng
progressBar.Left = .Left
progressBar.Top = .Top
progressBar.Width = .Width * progressValue
progressBar.Height = .Height
End With
End Sub