The following macro puts a rectangle on the sheet to show the completion status of a range of cells (A9:A20) - it should be fairly easy to edit this to show the bar based on a % complete figure in a specific cell.
Hope this helps.
JAF
Sub show_percentage_complete()
Dim CompletedRows
CompletedRows = Application.WorksheetFunction.CountA(Range("$A$9:$A$20"))
Dim RowsToComplete
RowsToComplete = Rows.Range("$A$9:$A$20").Count
Dim percent_wide As Long
percent_wide = ((CompletedRows / RowsToComplete) * 100) * 1.92
'100% bar has width of 192 (in this case), therefore 1% = 1.92
On Error GoTo create_shape
ActiveSheet.Shapes("Box1").Delete
create_shape:
'RED if less than 100% - NB: 100% is a value IN THIS CASE of 192 (as above)
If percent_wide < 192 Then
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 96, 0, percent_wide, 12.75).Select
With Selection
.Name = "Box1"
.ShapeRange.Fill.Visible = msoTrue
.ShapeRange.Fill.Solid
.ShapeRange.Fill.ForeColor.SchemeColor = 10
.ShapeRange.Line.Weight = 1#
.ShapeRange.Line.DashStyle = msoLineSolid
.ShapeRange.Line.Style = msoLineSingle
.ShapeRange.Line.Visible = msoTrue
.ShapeRange.Line.ForeColor.SchemeColor = 64
.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
End With
Else
'BLUE if 100%
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 96, 0, percent_wide, 12.75).Select
With Selection
.Name = "Box1"
.ShapeRange.Fill.Visible = msoTrue
.ShapeRange.Fill.Solid
.ShapeRange.Fill.ForeColor.SchemeColor = 12
.ShapeRange.Line.Weight = 1#
.ShapeRange.Line.DashStyle = msoLineSolid
.ShapeRange.Line.Style = msoLineSingle
.ShapeRange.Line.Visible = msoTrue
.ShapeRange.Line.ForeColor.SchemeColor = 64
.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
End With
End If
ActiveCell.Select
End Sub
Oops - I forgot to mention, in order for that code to work you need to have the following code in the Sheet object:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Call show_percentage_complete
End Sub
Whenever the sheet changes, the macro show_percentage_complete will be run.
Gerry
In the archives of this message board, have a look at judi's reply to Status Bars posted by Jim Bubb on February 02, 19100
Celia