Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Noelle
 
Posts: n/a
Default How do I create very small graphics in ONE cell?

I have data like following and I want to creat a line or 3 bars to reflect
the numbers in ONE cell so that people can quicky scan through the trend.

3,225 2,356 1,087

I tried wizard but it doesn't look good when you minimize it.
I tried autoshape but couldn't let the ahotopshap connect to the numbers.

My boss said he has seen people do this before. Does anyone know how to do it?

Thanks!
  #2   Report Post  
Tushar Mehta
 
Posts: n/a
Default How do I create very small graphics in ONE cell?

There's a couple of ways to go. The first is to adapt the idea behind
Using Worksheet Cells to simulate a graph
http://www.tushar-
mehta.com/excel/newsgroups/worksheet_as_chart/index.htm

While that uses conditional formatting as an example, the concept can
be easily extended to show a bar chart using multiple columns. In
addition to other more obvious benefits, you can even have the bars
change color depending on the value being shown. On the downside,
since the bar size will always be the width of a cell, the visual
representation will move in discrete steps rather than as a smooth
continuous shape.

A more complex alternative using a rectangle shape (from the Drawing
toolbar) would require code. The code below is a crude first-pass
solution. It works but can (should?) be made more robust.

It works by tracking column A values. Each value is expected to be
between 0 and 100. The code adds a rectangle positioned over column B.
The width of the rectangle reflects the value of the number in column
A. All these can be changed in the Worksheet_Change procedure below.

The first part of the code goes in the worksheet module. Note that
this is not something I would do in a 'full fledged' solution. In such
a case, the code would use a class module that included the appropriate
application level event to track changes. But, the below is easier for
demonstration purposes.

On to the code...

In the worksheet's code module:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Shape
If Target.Column = 1 Then
Set x = getShape(Target)
x.Width = _
Target.Value / 100 * Target.Offset(0, 1).Width
End If
End Sub

Next, in a standard module:
Option Explicit

Function addShape(aSheet As Worksheet, LocCell As Range) As Shape
Dim x As Shape
Set x = aSheet.Shapes.addShape( _
msoShapeRectangle, 47.25, 13.5, 48.75, 11.25)
With x
.Name = "Rect" & LocCell.Row
.Left = LocCell.Left
.Top = LocCell.Top
.Width = LocCell.Width
.Height = LocCell.Height
With .Fill
.Visible = msoTrue
.Solid
.ForeColor.SchemeColor = 10
.Transparency = 0#
End With
.Line.Visible = msoFalse
End With
Set addShape = x
End Function
Function getShape(Target As Range) As Shape
Dim x As Shape
On Error Resume Next
Set x = Target.Parent.Shapes("rect" & Target.Row)
On Error GoTo 0
If x Is Nothing Then
Set getShape = addShape(Target.Parent, Target.Offset(0, 1))
Else
Set getShape = x
End If
End Function

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I have data like following and I want to creat a line or 3 bars to reflect
the numbers in ONE cell so that people can quicky scan through the trend.

3,225 2,356 1,087

I tried wizard but it doesn't look good when you minimize it.
I tried autoshape but couldn't let the ahotopshap connect to the numbers.

My boss said he has seen people do this before. Does anyone know how to do it?

Thanks!

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
How can I create a new line in a cell in Excel by hitting enter? Monica Excel Discussion (Misc queries) 4 July 1st 05 06:32 PM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
create a cell that accumulates, numbers from another cell... sombull Excel Discussion (Misc queries) 1 February 18th 05 04:45 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM
Using the results from two seperate cells to create cell reference DarrenWood Excel Worksheet Functions 2 November 14th 04 10:35 PM


All times are GMT +1. The time now is 10:18 AM.

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

About Us

"It's about Microsoft Excel"