+ Reply to Thread
Results 1 to 2 of 2

accessing x-axis of line chart

  1. #1
    Registered User
    Join Date
    03-11-2012
    Location
    china
    MS-Off Ver
    Excel 2007
    Posts
    3

    accessing x-axis of line chart

    Hi Guys,
    I am working with line charts and i am successively drawing line charts based on the number of rows. Each row contains one line chart and every time chart is drawn on new worksheet (e.g., if there are 5 rows then on single click 5 line charts will be drawn).
    The problem that i am facing is, How to put column headings on the x-axis of each chart.
    NOTE: Row heading is already appearing on the y-axis of each chart.
    I have also attached my excel sheet for better understanding the problem.....I want DP1, DP2, DP3,....on the x-axis of each line graph.
    Here is my code:

    Sub LineCharts()
    Dim Ws As Worksheet
    Dim NewWs As Worksheet
    Dim cht As Chart
    Dim LastRow As Long
    Dim CurrRow As Long

    Set Ws = ThisWorkbook.Worksheets("Sheet1")

    LastRow = Ws.Range("A65536").End(xlUp).Row
    For CurrRow = 2 To LastRow
    Set NewWs = ThisWorkbook.Worksheets.Add
    NewWs.Name = Ws.Range("A" & CurrRow).Value
    Set cht = ThisWorkbook.Charts.Add
    With cht
    .ChartType = xlLine
    .SeriesCollection.NewSeries

    .SeriesCollection(1).Values = "=" & Ws.Name & "!R" & CurrRow & "C3:R" & CurrRow & "C8"
    .SeriesCollection(1).Name = "=" & Ws.Name & "!R" & CurrRow & "C2"
    .Location Where:=xlLocationAsObject, Name:=NewWs.Name
    End With
    Next CurrRow
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: accessing x-axis of line chart

    Hi moonstar

    Welcome to the Forum....

    Please wrap your code in code tags, before the moderators get you...

    Click here - Forum rules
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.
    Also What is the difference with this Post putting column headings on the x-axis of each line chart
    Cheers

+ 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