Results 1 to 3 of 3

Creating Charts from List Using VBA Loop

Threaded View

  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    9

    Creating Charts from List Using VBA Loop

    I am trying to create a VBA loop to build line graphs. I want the loop to look at a reference tab and create each graph on a new named tab accordingly to my list. I have pasted my code below (I am VBA novice--this is what I have been able to string together via MANY web searches). I have attached a dummy file, including what I want the graphs to look like.

    Sub GrphLoop()
    '
    ' GrphLoop Macro
    '
    
    Dim sheet_name As Range
    Dim graph_name As Range
    For Each sheet_name In Sheets("REFACCTS").Range("A:A")
    For Each graph_name In Sheets("REFACCTS").Range("B:B")
        If sheet_name.Value = "" Then
            Exit For
        Else
        
       
        Sheets(sheet_name.Value).Select
        Range("B:B,F:K").Select
        Sheets(sheet_name.Value).Select
        ActiveChart.SetSourceData Source:=Range("$B:$B,$F:$K")
        Charts.Add
        ActiveChart.ChartType = xlLine
    
       ActiveSheet.Name = graph_name.Value
       Sheets(graph_name.Value).Move Before:=Sheets(3)
        
      
        ActiveChart.ChartArea.Select
        ActiveChart.PlotArea.Select
        Selection.Height = 344.64
        Selection.Top = 96.102
        ActiveChart.Legend.Select
        Selection.Delete
        Cells.Select
        With Selection.Font
            .Name = "Frutiger 55 Roman"
            .Size = 11
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With Selection.Font
            .Name = "Frutiger 55 Roman"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight1
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With Selection.Font
            .ThemeColor = xlThemeColorAccent1
            .TintAndShade = -0.249977111117893
        End With
        Range("A1").Select
        ActiveCell.FormulaR1C1 = sheet_name
        Range("A2").Select
        ActiveCell.FormulaR1C1 = "CUMULATIVE GROWTH OF CAPITAL SINCE INCEPTION"
        Range("A3").Select
        ActiveCell.FormulaR1C1 = "NET OF FEES AS OF:"
         Range("D3").Select
         ActiveCell.FormulaR1C1 = _
            "=UPPER(TEXT(INDEX((sheet_name.value)C[-2],COUNTA(sheet_name.value)C[-2]),1),""mmmm d, yyyy""))"
        
        
          Dim mySrs As Series
          Dim nPts As Long
          For Each mySrs In ActiveChart.SeriesCollection
          With mySrs
            nPts = .Points.Count
            mySrs.Points(nPts).ApplyDataLabels _
                Type:=xlDataLabelsShowValue, _
                AutoText:=True, LegendKey:=False
            mySrs.Points(nPts).DataLabel.Text = mySrs.Name
          End With
    
    End If
    
          Next sheet_name
    Attached Files Attached Files
    Last edited by JBeaucaire; 05-08-2014 at 06:10 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating 100 charts from a long list of data
    By Need Help Please in forum Excel General
    Replies: 1
    Last Post: 05-10-2012, 02:38 AM
  2. Help with loop for creating list in excel
    By DrSpliff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-07-2011, 07:10 AM
  3. Creating a list of variables at the end of a For Each Loop
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-13-2010, 05:03 PM
  4. Creating simple charts from multiple pivot table charts
    By hovaucf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2008, 04:13 PM
  5. Problem adding charts using Do-Loop Until loop
    By Chris Bromley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2005, 09:06 AM

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