Numbering Charts in a Worksheet Grid

Many of the models I work with require a series of embedded charts to appear on a single worksheet. Each chart is usually numbered for reference. The numbers usually appear in a worksheet cell directly above the right-side of each embedded chart.

Below is a macro that will quickly add a number for each embedded chart to a cell on the upper right-side of the chart:

Sub NumberCharts()

    Dim i As Integer
    Dim Rng As Range
    Dim ColumnsAcross As Integer
    Dim RowsDown As Integer

    '*************************************************

    'The range where you want the first "Chart 1" to appear

    Set Rng = ActiveSheet.Range("F3")

    '# of columns to the right that you want "Chart 2" to appear

    ColumnsAcross = 5

    '# of rows down that you want "Chart 3" to appear

    RowsDown = 13

    '*************************************************

    i = 0

    Do Until i = ActiveSheet.ChartObjects.Count

        i = i + 1

        Rng.Value = "Chart " & i
        Rng.HorizontalAlignment = xlRight

        i = i + 1

        Rng.Offset(0, ColumnsAcross).Value = "Chart " & i
        Rng.Offset(0, ColumnsAcross).HorizontalAlignment = xlRight

        Set Rng = Rng.Offset(RowsDown, 0)

    Loop

End Sub

The numbers appear on the upper right-side of the chart similar to below:

image

Posted on May 15, 2010 | Filed under: Charts | Comments (0) | Permalink
Page 1 of 1 pages

Comments

Comment Entry

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

Statistics

  • Total Entries - 136
  • Current Viewers - 24

Categories

Entries by Day

Sep - 2010
S M T W T F S
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 1 2

Recent Comments

Syndicate