+ Reply to Thread
Results 1 to 9 of 9

Remove Chart Area Border - Where in Code is it Added?

Hybrid View

Janc Remove Chart Area Border -... 06-12-2011, 06:26 PM
abishekmouli88 Re: Remove Chart Area Border... 06-12-2011, 06:31 PM
TMS Re: Remove Chart Area Border... 06-12-2011, 06:34 PM
Janc Re: Remove Chart Area Border... 06-12-2011, 06:44 PM
Jbentley Re: Remove Chart Area Border... 06-12-2011, 07:58 PM
Janc Re: Remove Chart Area Border... 06-13-2011, 03:32 AM
TMS Re: Remove Chart Area Border... 06-13-2011, 04:09 AM
Janc Re: Remove Chart Area Border... 06-13-2011, 06:36 AM
TMS Re: Remove Chart Area Border... 06-13-2011, 06:40 AM
  1. #1
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Question Remove Chart Area Border - Where in Code is it Added?

    I have very little knowledge of editing Visual Basic and I'm a little stuck on something: somewhere within this code (below) I am getting a chart area border showing on my graphs - but I don't want a border and cant find the coding to remove it. (I previously had Excel 03 and found this easier as I would record a macro and look at the coding to see where I needed to edit, but I can't seem to do that in 07


    Could someone point out how I could remove the border please (do I need to attach a sample workbook for this?)

    Many thanks in advance.



     'grab name for new chart and title
        aName = ws.Cells(iRow, 1)
        'delete old chart
        Sheets(aName).Delete
        'make new chart
        Charts.Add
        ActiveSheet.Move after:=Sheets(ActiveWorkbook.Sheets.Count)
        ActiveChart.ChartType = xlBarClustered
        ActiveChart.SetSourceData _
              Source:=ws.Range(ws.Cells(4 * iRow - 11, 7), _
              ws.Cells(4 * iRow - 9, 9)), PlotBy:=xlRows
        ActiveChart.Location Where:=xlLocationAsNewSheet, _
             Name:=aName
        With ActiveChart
            .Name = aName
            .HasTitle = True
            .ChartTitle.Characters.Text = "Average Times - 1st January to 31st March 2011" & Chr(10) & Chr(10) & Chr(10) & "Consultant- " & aName & Chr(10) & Chr(10) & "Sample Size - Adv: " & Sheets("Adv & TC Ave").Cells(iRow, 5) & Chr(10) & "Sample Size - TC: " & Sheets("Adv & TC Ave").Cells(iRow, 4) & Chr(10)
            .Axes(xlCategory, xlPrimary).HasTitle = False
            .Axes(xlValue, xlPrimary).HasTitle = False
            End With
        
        ActiveChart.HasLegend = True
        ActiveChart.Legend.Select
        ActiveChart.Legend.Font.Size = 12
        Selection.Position = xlTop
        ActiveChart.ApplyDataLabels AutoText:=True, LegendKey:=False, _
            HasLeaderLines:=False, ShowSeriesName:=False, ShowCategoryName:=False, _
            ShowValue:=True, ShowPercentage:=False, ShowBubbleSize:=False
        ActiveChart.SeriesCollection(2).DataLabels.Select
        Selection.NumberFormat = "0"
        ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
        ActiveChart.SeriesCollection(1).Select
        With ActiveChart.ChartGroups(1)
            .Overlap = -10
            .GapWidth = 100
            .HasSeriesLines = False
            .VaryByCategories = False
        End With
        
        ActiveChart.PlotArea.Select
        With Selection.Border
            .ColorIndex = 16
            .Weight = xlThin
            .LineStyle = xlContinuous
        End With
        Selection.Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=3, _
            Degree:=1
        With Selection
            .Fill.Visible = True
            .Fill.ForeColor.SchemeColor = 24
        End With
        ActiveChart.SeriesCollection(1).Select
        With Selection.Border
            .Weight = xlThin
            .LineStyle = xlAutomatic
        End With
        Selection.Shadow = False
        Selection.InvertIfNegative = False
        Selection.Fill.Patterned Pattern:=msoPatternLightUpwardDiagonal
        With Selection
            .Fill.Visible = True
            .Fill.ForeColor.SchemeColor = 55
            .Fill.BackColor.SchemeColor = 2
        ActiveChart.SeriesCollection(2).Select
        With Selection.Border
            .Weight = xlThin
            .LineStyle = xlAutomatic
        End With
        Selection.Shadow = False
        Selection.InvertIfNegative = False
        With Selection.Interior
            .ColorIndex = 55
            .Pattern = xlSolid
        End With
        With ActiveChart
            .Axes(xlCategory, xlPrimary).HasTitle = False
            .Axes(xlValue, xlPrimary).HasTitle = True
            .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = _
            "Average Time In Minutes"
        End With
        ActiveChart.Axes(xlValue).MajorGridlines.Select
        With Selection.Border
            .ColorIndex = 48
            .Weight = xlHairline
            .LineStyle = xlContinuous
        End With
        With ActiveChart.SeriesCollection(2).DataLabels.Select
        Selection.NumberFormat = "0"
        ActiveChart.SeriesCollection(1).DataLabels.Select
        Selection.NumberFormat = "0"
        End With
        
        ActiveChart.Axes(xlValue).Select
        With ActiveChart.Axes(xlValue)
            .MinimumScaleIsAuto = 0
            .MaximumScale = 60
            .MinorUnitIsAuto = True
            .MajorUnitIsAuto = True
            .Crosses = xlAutomatic
            .ReversePlotOrder = False
            .ScaleType = xlLinear
            .DisplayUnit = xlNone
        End With
        ActiveChart.ChartArea.Select
        ActiveChart.Deselect
        
        End With
        
      
        
        ActiveChart.SeriesCollection(2).DataLabels.Select
        Selection.AutoScaleFont = False
        With Selection.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        ActiveChart.SeriesCollection(1).DataLabels.Select
        Selection.AutoScaleFont = False
        With Selection.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        ActiveChart.Axes(xlCategory).Select
        Selection.TickLabels.AutoScaleFont = True
        With Selection.TickLabels.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        ActiveChart.Axes(xlValue).AxisTitle.Select
        Selection.AutoScaleFont = False
        With Selection.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        ActiveChart.Axes(xlValue).Select
        Selection.TickLabels.AutoScaleFont = True
        With Selection.TickLabels.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        ActiveChart.ChartTitle.Select
        Selection.AutoScaleFont = False
        With Selection.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        ActiveChart.Legend.Select
        Selection.AutoScaleFont = False
        With Selection.Font
            .Name = "Calibri"
            .Size = 14
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        
        
            
        iRow = iRow + 1
    Loop Until ws.Cells(iRow, 1) = ""
    Application.DisplayAlerts = True
    
    
    
    End Sub
    Last edited by Janc; 06-13-2011 at 03:31 AM.

  2. #2
    Registered User
    Join Date
    05-11-2011
    Location
    College Station, Texas
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    42

    Re: Remove Chart Area Border - Where in Code is it Added?

    Hi Janc,

    If you can attach me a sample file, I can set it right for you

    Regards,
    Abi
    Abi

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,110

    Re: Remove Chart Area Border - Where in Code is it Added?

    If you can remove it manually, record a macro while you do it. Then find the equivalent code in your macro and modify it.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Re: Remove Chart Area Border - Where in Code is it Added?

    Thank you Abi, sample file attached



    Thanks also TM Shucks Manually removing and recording was exactly how I tried to do it (as this used to work for me when I had '03), but this was all I got from 07:

    Sub bordertest()
    '
    ' bordertest Macro
    '
    
    '
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.PlotArea.Select
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.ChartArea.Select
        ActiveSheet.ChartObjects("Chart 1").Activate
    End Sub


    It didn't appear to record that I added a border and then removed it, but I'm still very much finding my way around '07 as it was only installed very recently.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    04-03-2007
    Location
    Auckland, New Zealand
    MS-Off Ver
    2007
    Posts
    137

    Re: Remove Chart Area Border - Where in Code is it Added?

    Hi,
    The border is applied by default, so you may not see the code.

    To remove the border try:
        ActiveChart.ChartArea.Select
        With Selection.Border
            .ColorIndex = xlNone
        End With
    Last edited by Jbentley; 06-12-2011 at 07:59 PM. Reason: change end tag on code

  6. #6
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Re: Remove Chart Area Border - Where in Code is it Added?

    Jbentley, thank you so much, that works perfectly!
    Last edited by Janc; 06-13-2011 at 03:36 AM. Reason: Spelling

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,110

    Re: Remove Chart Area Border - Where in Code is it Added?

    Just as an aside, you can make your code much shorter, more efficient and quicker by:

    * removing all the default settings for fonts, etc
    * using With ... End With instead of xxx.Select ... Selection ...
    * enclosing your code in ... ScreenUpdating=False / ScreenUpdating = True

    I have adjusted some, but not all, of your code in the attached, updated, workbook.

    Regards
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-30-2009
    Location
    UK
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    60

    Re: Remove Chart Area Border - Where in Code is it Added?

    This helps a lot as I was aware there was a lot of code in there that probably didn't need to be so I will go through now using your edits as examples and see which parts I can take out.

    Thanks for going to the trouble of looking at my code, it's very much appreciated

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,110

    Re: Remove Chart Area Border - Where in Code is it Added?

    You're welcome. Thanks for the rep.

    I learn as much from doing this as others benefit from it so it's a mutual gain.

    Regards

+ 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