+ Reply to Thread
Results 1 to 2 of 2

Referencing sheets/objects

  1. #1
    Registered User
    Join Date
    02-16-2006
    Posts
    1

    Referencing sheets/objects

    Hi,

    I am new to writing macros for excel and have a problem I need some help with:

    I want to add a chart using data from the active sheet. I tried the code below. I know it's writing the active sheet name to CSheet because I can read it using msgbox so why won't the reference work??

    CSheet = ActiveSheet.Name
    Charts.Add
    ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
    ActiveChart.SetSourceData Source:=Sheets("CSheet").Range("C16:D82"), PlotBy _
    :=xlColumns
    ActiveChart.Location Where:=xlLocationAsObject, Name:="CSheet"
    etc..

  2. #2
    Norman Jones
    Guest

    Re: Referencing sheets/objects

    Hi DVE11,

    Change:

    Name:="CSheet"
    to
    Name:=CSheet


    ---
    Regards,
    Norman



    "dve11" <dve11.23bl8a_1140089702.404@excelforum-nospam.com> wrote in message
    news:dve11.23bl8a_1140089702.404@excelforum-nospam.com...
    >
    > Hi,
    >
    > I am new to writing macros for excel and have a problem I need some
    > help with:
    >
    > I want to add a chart using data from the active sheet. I tried the
    > code below. I know it's writing the active sheet name to CSheet
    > because I can read it using msgbox so why won't the reference work??
    >
    > CSheet = ActiveSheet.Name
    > Charts.Add
    > ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
    > ActiveChart.SetSourceData
    > Source:=Sheets("CSheet").Range("C16:D82"), PlotBy _
    > :=xlColumns
    > ActiveChart.Location Where:=xlLocationAsObject, Name:="CSheet"
    > etc..
    >
    >
    > --
    > dve11
    > ------------------------------------------------------------------------
    > dve11's Profile:
    > http://www.excelforum.com/member.php...o&userid=31618
    > View this thread: http://www.excelforum.com/showthread...hreadid=513129
    >




+ 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