+ Reply to Thread
Results 1 to 2 of 2

Creating a Macro that returns charts. Keep getting error

  1. #1
    Registered User
    Join Date
    06-06-2012
    Location
    ATLANTA, GA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Creating a Macro that returns charts. Keep getting error

    Hey guys. I'm in the process of creating a macro that will return charts based off of data from another worksheet. Unfortunately, I keep getting an error. I'm new to the whole VBA thing and I'm not really sure why its not working.

    Here's the code:


    Sub Charts()
    '
    ' Charts Macro
    ' Macro recorded 6/28/2012 by MAC35
    '
    ' Keyboard Shortcut: Ctrl+Shift+H
    '
    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=Sheets("SUMMARY").Range("B12:G17"), PlotBy _
    :=xlColumns
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Charts"
    With ActiveChart
    .HasTitle = True
    .ChartTitle.Characters.Text = "VW Weekly"
    .Axes(xlCategory, xlPrimary).HasTitle = False
    .Axes(xlValue, xlPrimary).HasTitle = False
    End With
    ActiveChart.HasDataTable = True
    ActiveChart.DataTable.ShowLegendKey = False
    ActiveChart.PlotArea.Select
    ActiveChart.ChartArea.Select
    ActiveSheet.Shapes("Chart 13").IncrementLeft -231.75
    ActiveSheet.Shapes("Chart 13").IncrementTop -160.5
    ActiveSheet.Shapes("Chart 13").ScaleWidth 0.92, msoFalse, msoScaleFromTopLeft
    End Sub


    MVB states that the error is with the first line. The error reads: compile error expected function or variable.


    Thanks in advance

  2. #2
    Registered User
    Join Date
    06-06-2012
    Location
    ATLANTA, GA
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Creating a Macro that returns charts. Keep getting error

    I tried working around the problem by just recording a macro this time, but I received another error regarding the positioning.


    Sub VWwkChart()
    '
    ' VWwkChart Macro
    ' Macro recorded 6/28/2012 by MAC35
    '
    ' Keyboard Shortcut: Ctrl+Shift+H
    '
    Sheets("SUMMARY").Select
    Range("B12:G17").Select
    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=Sheets("SUMMARY").Range("B12:G17"), PlotBy _
    :=xlColumns
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Charts"
    With ActiveChart
    .HasTitle = True
    .ChartTitle.Characters.Text = "VW Weekly"
    .Axes(xlCategory, xlPrimary).HasTitle = False
    .Axes(xlValue, xlPrimary).HasTitle = False
    End With
    ActiveChart.HasDataTable = True
    ActiveChart.DataTable.ShowLegendKey = False
    ActiveSheet.Shapes("Chart 14").IncrementLeft -231.75
    ActiveSheet.Shapes("Chart 14").IncrementTop -160.5
    ActiveSheet.Shapes("Chart 14").ScaleWidth 0.91, msoFalse, msoScaleFromTopLeft
    End Sub


    Not really sure what to do about that.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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