+ Reply to Thread
Results 1 to 2 of 2

Cell reference based on active cell

Hybrid View

  1. #1
    Registered User
    Join Date
    01-21-2011
    Location
    Mars
    MS-Off Ver
    Excel 2007
    Posts
    7

    Cell reference based on active cell

    Is there a way to create the chart below based on the active cell I select in a worksheet. Say if I select cell R1 a chart will be created based on that reference so the reference L and M will increase by two letters to T and U reference?

       ActiveChart.ChartType = xlXYScatterLines
        ActiveChart.PlotArea.Select
        ActiveChart.SeriesCollection.NewSeries
        ActiveChart.SeriesCollection(2).XValues = "='" & ActiveSheet.Name & "'!$L$37:$L$49"
        ActiveChart.SeriesCollection(2).Values = "='" & ActiveSheet.Name & "'!$M$37:$M$49"

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,466

    Re: Cell reference based on active cell

    
       Dim rngData As Range
    
       Set rngData = Intersect(ActiveCell.Offset(, 2).EntireColumn, ActiveSheet.Range("37:49"))
    
        With ActiveChart
            .ChartType = xlXYScatterLines
            With .SeriesCollection.NewSeries
                .XValues = rngData
                .Values = rngData.Offset(, 1)
            End With
        End With
    Cheers
    Andy
    www.andypope.info

+ 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