Consulting

Results 1 to 5 of 5

Thread: chart to be created in new sheet This macro creates chart in the worksheet same as da

  1. #1
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    chart to be created in new sheet This macro creates chart in the worksheet same as da

    This macro creates chart in the worksheet same as data. Plse add code so that chart can be created in new worksheet.
    [VBA]Range("A4:C19").Select
    ActiveSheet.Shapes.AddChart.Select ActiveChart.ChartType = xlLineMarkers ActiveChart.SetSourceData Source:=Range("'P11'!$A$4:$C$19") End Sub [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Add this

    [vba]
    ActiveChart.Location xlLocationAsNewSheet[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    chart to be created in new sheet This macro creates chart in the worksheet same as da

    your code added but: comile error;use of property at
    xlLocationAsNewSheet
    [VBA]ActiveChart.Location
    xlLocationAsNewSheet
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlLineMarkers
    ActiveChart.SetSourceData Source:=Range("'P11'!$A$4:$C$28")
    End Sub[/VBA]

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You add it all in ONE line, AFTER your code. You cannot reference ActiveChart before there is one.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    chart to be created in new sheet This macro creates chart in the worksheet same as da

    ok
    thank you

Posting Permissions

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