Home |
Search |
Today's Posts |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() The function below is altered using Patricks post above. I need to display a bar depicting the percentage listed in a cell. I can pass a value between .1 and 1.0 and the bar will fill that percentage of the cell. However, I want to test for the presence of a rectangle and alter the width of the existing rectangle rather than create another rectangle on top of an existing one. I also want to change the font color to white so the "0" that normally displayed is effectively hidden. I would appreciate any help with the following; - How do I test for the presence of the shape in the cell. - How do I change the width of the cell once I determine a rectangle already exists? - How do I set the cell's font color to white to hide the "0" thats displayed? Code: -------------------- Function ProgressBar(percent_fill) Dim cell As Range Dim sh As Shape Set cell = Application.Caller cell.Select x = 0 'Used to force condition for now 'Set font color cell.Font.Color = RGB(255, 255, 255) 'Calculate percentage of cell to fill in cwidth = cell.width * percent_fill 'Check if a shape is already present (How do I test for the shape?) If x = 0 Then 'If not create the shape to desired width (This seems to work) ActiveSheet.Shapes.AddShape(msoShapeRectangle, cell.Left, cell.Top, cwidth, cell.Height).Select With Selection .ShapeRange.Fill.ForeColor.SchemeColor = 30 .ShapeRange.Fill.Visible = msoTrue .ShapeRange.Fill.Solid .Name = "PB" & cell.Name End With Else 'If so, alter the width of the existing shape (Not working) Set sh = ActiveSheet.Shapes("PB" & cell.Name) sh.width = 0 sh.width = cwidth End If End Function -------------------- Any help would be appreciated. -- markyharris ------------------------------------------------------------------------ markyharris's Profile: http://www.excelforum.com/member.php...o&userid=24823 View this thread: http://www.excelforum.com/showthread...hreadid=381866 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Tracking progress and coloring numbers in a cell | Excel Discussion (Misc queries) | |||
Progress Bar | Excel Programming | |||
Data Entry in a cell still in progress - how to detect and correct | Excel Programming | |||
Progress Bar | Excel Programming | |||
Progress Bar Help | Excel Programming |