Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default proportionally fill a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default proportionally fill a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default proportionally fill a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default proportionally fill a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default proportionally fill a cell

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Fill Cell Based on Data in a different cell JB Bates[_2_] Excel Discussion (Misc queries) 4 October 15th 09 04:17 PM
remove fill in text from a cell from an unpopulated fill-in cell Deb[_3_] Excel Worksheet Functions 1 September 22nd 09 03:28 PM
Proportionally weighted random generator? WildlyHarry Excel Discussion (Misc queries) 3 June 10th 07 04:11 PM
How do I automatically fill a cell based on another cell in Excel SouthCarolina Excel Discussion (Misc queries) 3 January 13th 06 12:52 AM
Auto-fill cell based on adjacent cell information.. sans Excel Worksheet Functions 1 October 17th 05 11:38 PM


All times are GMT +1. The time now is 05:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"