Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is this possible:
I'm looking for a way to proportionally fill a cell based on the contents. For example, if the contents of four rows a ..8 ..75 ..5 1 then the contents of these cells are 4/5, 3/4, 1/2, and completely full....(either top to bottom or left to right). Right now I'm using a stacked bar graph, but lining up the axes of the graph on top of the the cell gridlines is quite a challenge and very time consuming. I'm not optimistic, but thought I would put this question out here to check. Many thanks in advance. MJohn |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Option Explicit
Sub Macro1() Dim c As Range Dim v As Single Dim s As Shape For Each c In Selection If c.Value = 0 And c.Value <= 1 Then v = c.Value Set s = ActiveSheet.Shapes.AddShape(msoShapeRectangle, _ c.Left, c.Top, c.Width * v, c.Height) s.Fill.Visible = msoTrue s.Fill.ForeColor.SchemeColor = 44 s.Fill.Transparency = 0.67 End If Next c End Sub -- Tim Williams Palo Alto, CA "M John" wrote in message ... Is this possible: I'm looking for a way to proportionally fill a cell based on the contents. For example, if the contents of four rows a .8 .75 .5 1 then the contents of these cells are 4/5, 3/4, 1/2, and completely full....(either top to bottom or left to right). Right now I'm using a stacked bar graph, but lining up the axes of the graph on top of the the cell gridlines is quite a challenge and very time consuming. I'm not optimistic, but thought I would put this question out here to check. Many thanks in advance. MJohn |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That's beautiful. Simple. Perfect.
Uhhh-Mayzing. Many thanks, MJohn "Tim Williams" wrote: Option Explicit Sub Macro1() Dim c As Range Dim v As Single Dim s As Shape For Each c In Selection If c.Value = 0 And c.Value <= 1 Then v = c.Value Set s = ActiveSheet.Shapes.AddShape(msoShapeRectangle, _ c.Left, c.Top, c.Width * v, c.Height) s.Fill.Visible = msoTrue s.Fill.ForeColor.SchemeColor = 44 s.Fill.Transparency = 0.67 End If Next c End Sub -- Tim Williams Palo Alto, CA "M John" wrote in message ... Is this possible: I'm looking for a way to proportionally fill a cell based on the contents. For example, if the contents of four rows a .8 .75 .5 1 then the contents of these cells are 4/5, 3/4, 1/2, and completely full....(either top to bottom or left to right). Right now I'm using a stacked bar graph, but lining up the axes of the graph on top of the the cell gridlines is quite a challenge and very time consuming. I'm not optimistic, but thought I would put this question out here to check. Many thanks in advance. MJohn |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You want to select some quantity of cells and fill them with different colors
to make them look like a stacked bar graph based on the values in some other cells? How many cells? Do you mean 4 cells and you want to adjust the height or width? Anyway, more information might garner a different response. -- Regards, Tom Ogilvy "M John" wrote: Is this possible: I'm looking for a way to proportionally fill a cell based on the contents. For example, if the contents of four rows a .8 .75 .5 1 then the contents of these cells are 4/5, 3/4, 1/2, and completely full....(either top to bottom or left to right). Right now I'm using a stacked bar graph, but lining up the axes of the graph on top of the the cell gridlines is quite a challenge and very time consuming. I'm not optimistic, but thought I would put this question out here to check. Many thanks in advance. MJohn |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The macro code supplied by Mr. Williams does exactly what I need....and I
modified slightly to be: Sub Proportionally_Fill() Dim c As Range Dim v As Single Dim s As Shape For Each c In Selection If c.Value = 0 And c.Value <= 1 Then v = c.Value Set s = ActiveSheet.Shapes.AddShape(msoShapeRectangle, _ c.Left, c.Top, c.Width * v, c.Height) s.Fill.Visible = msoTrue s.Fill.ForeColor.SchemeColor = 17 s.Line.Visible = msoFalse Selection.Font.ColorIndex = 2 End If Next c End Sub Which allows me to select any number of cells and fill those cells propotionally (left to right) based on the values in those cells. Thanks for the quick reply. MJohn "Tom Ogilvy" wrote: You want to select some quantity of cells and fill them with different colors to make them look like a stacked bar graph based on the values in some other cells? How many cells? Do you mean 4 cells and you want to adjust the height or width? Anyway, more information might garner a different response. -- Regards, Tom Ogilvy "M John" wrote: Is this possible: I'm looking for a way to proportionally fill a cell based on the contents. For example, if the contents of four rows a .8 .75 .5 1 then the contents of these cells are 4/5, 3/4, 1/2, and completely full....(either top to bottom or left to right). Right now I'm using a stacked bar graph, but lining up the axes of the graph on top of the the cell gridlines is quite a challenge and very time consuming. I'm not optimistic, but thought I would put this question out here to check. Many thanks in advance. MJohn |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto Fill Cell Based on Data in a different cell | Excel Discussion (Misc queries) | |||
remove fill in text from a cell from an unpopulated fill-in cell | Excel Worksheet Functions | |||
Proportionally weighted random generator? | Excel Discussion (Misc queries) | |||
How do I automatically fill a cell based on another cell in Excel | Excel Discussion (Misc queries) | |||
Auto-fill cell based on adjacent cell information.. | Excel Worksheet Functions |