+ Reply to Thread
Results 1 to 2 of 2

Automatically Tiling Graphs

  1. #1
    Registered User
    Join Date
    01-27-2005
    Posts
    1

    Angry Automatically Tiling Graphs

    I have a macro that automatically creates a large number of graphs. Unfortunately, the graphs end up exactly on top of one another. Does anyone know a macro command that would allow me to tile an arbitrary number of graphs?

    Thanks,
    Eric
    Last edited by matrixee; 01-27-2005 at 06:39 PM.

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    I am making all the charts of same width and height

    You can go throught the code comments.

    You have option to change the width,height of chart, number of charts per row.

    I want you to backup the original file and try this macro


    Sub Macro1()

    Dim width_c, height_c, chart_in_row As Variant

    Dim i As Integer
    Dim count As Variant
    Dim k, k1, k2 As Variant
    k = 1
    i = 0
    k1 = 1
    k2 = 0
    width_c = 250 'defining the width of the chart
    height_c = 250 'defining the height of the chart
    chart_in_row = 3 'defining number of charts in row
    count = ActiveSheet.ChartObjects.count 'number of charts
    MsgBox count
    While i = 0
    If k2 = count Then
    i = 1
    End
    End If
    For c = 1 To chart_in_row
    If k2 = count Then ' checking to see if all charts are covered
    i = 1
    End
    End If
    On Error Resume Next
    ActiveSheet.ChartObjects("Chart " & k).Activate
    If Err.Description <> "" Then
    c = c - 1
    Err.Clear
    Else
    ActiveChart.ChartArea.Select
    ActiveSheet.Shapes("Chart " & k).Left = (width_c * c) - width_c ' assigning left position value
    ActiveSheet.Shapes("Chart " & k).Height = height_c ' assigning height value
    ActiveSheet.Shapes("Chart " & k).Width = width_c ' assigning width value
    ActiveSheet.Shapes("Chart " & k).Top = (height_c * k1) - height_c 'assigning top position value
    k2 = k2 + 1 ' incrementing number of charts found value
    End If
    k = k + 1 ' incrementing chart array value
    Next
    k1 = k1 + 1 'incrementing rows
    Wend

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1