+ Reply to Thread
Results 1 to 7 of 7

Name only one bar in a diagram

Hybrid View

LittleV Name only one bar in a diagram 10-09-2008, 03:11 AM
Andy Pope Can you post example of data... 10-09-2008, 05:33 AM
LittleV Example 10-14-2008, 09:38 AM
Andy Pope Sub Macro2() ' ' Macro2... 10-14-2008, 09:52 AM
LittleV Thank you!! 10-14-2008, 11:33 AM
Andy Pope Please keep your questions in... 10-14-2008, 11:50 AM
LittleV Thank you! Case solved!! 10-14-2008, 12:35 PM
  1. #1
    Registered User
    Join Date
    09-13-2004
    Posts
    5

    Name only one bar in a diagram

    Hei!
    Have another problem too. I have a list in Excel with 2 rows. One with names and one with data. The list has 30 rows. I want to create 30 diagrams with all data in bu only showing the name for one of the persons. The other bars should be "nonamed". And is it possible to create all 30 diagrams in "one click"?
    Thanks for all tips you might have,

    Jonny
    Last edited by VBA Noob; 10-14-2008 at 01:15 PM. Reason: Case solved

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    Can you post example of data layout and chart

    To create all charts in 1 click would obviously require code.
    Will the example workbook also help solve your other post?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    09-13-2004
    Posts
    5

    Example

    In a1-a30 I have different names like: a1=Ann, a2=Toby, a3=Catherine
    In b1-b30 I have different data like: b1=200, b2=220, b3=380
    In b31=I have the average av column B. Lets use 270

    The chart I would like to create is in Chart1: 2 bars with Ann=220 and the average value.

    In chart 2: 2 bars wtih Toby and the average value.

    And over and over down to row 30.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    Sub Macro2()
    '
    ' Macro2 Macro
    ' Macro recorded 14/10/2008 by Andy Pope
    '
        Dim rngData As Range
        Dim rngAverage As Range
        Dim sngHeight As Single, sngWidth As Single
        Dim sngTop As Single, sngLeft As Single
        
        ' chartobject size
        sngTop = 1
        sngLeft = Range("E1").Left
        sngHeight = Range("A1:A7").Height
        sngWidth = Range("E1:K1").Width
        
        Set rngAverage = Range("A31:B31")
        For Each rngData In Range("A1:B30").Rows
            With ActiveSheet.ChartObjects.Add(sngLeft, sngTop, sngWidth, sngHeight).Chart
                .ChartType = xlBarClustered
                .SetSourceData Source:=Union(rngData, rngAverage), PlotBy:=xlColumns
                .PlotArea.Interior.ColorIndex = xlAutomatic
                .HasLegend = False
                With .Axes(xlCategory)
                    .Crosses = xlMaximum
                    .ReversePlotOrder = True
                End With
            End With
            sngTop = sngTop + sngHeight
        Next
        
    End Sub

  5. #5
    Registered User
    Join Date
    09-13-2004
    Posts
    5

    Thank you!!

    Hi!

    Thank you very much for spending so much time helping me to fix this!! Thanks again!!!

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    Please keep your questions in the thread.

    Thanks for your help!! It worked perfect!! One extra question. I will send out 1 page to each person at my work. Is it possible to have one chart at on each page like Sheet1, sheet2 and so on? Thanks. Jon
    Either one of this will do it
    Sub ChartPerSheet()
    '
    ' Macro2 Macro
    ' Macro recorded 14/10/2008 by Andy Pope
    '
        Dim rngData As Range
        Dim rngAverage As Range
        Dim sngHeight As Single, sngWidth As Single
        Dim sngTop As Single, sngLeft As Single
        Dim shtTemp As Worksheet
        
        ' chartobject size
        sngTop = 1
        sngLeft = Range("E1").Left
        sngHeight = Range("A1:A7").Height
        sngWidth = Range("E1:K1").Width
        
        Set rngAverage = Range("A31:B31")
        For Each rngData In Range("A1:B30").Rows
            Set shtTemp = Worksheets.Add(after:=Worksheets(Worksheets.Count))
            With shtTemp.ChartObjects.Add(sngLeft, sngTop, sngWidth, sngHeight).Chart
                .ChartType = xlBarClustered
                .SetSourceData Source:=Union(rngData, rngAverage), PlotBy:=xlColumns
                .PlotArea.Interior.ColorIndex = xlAutomatic
                .HasLegend = False
                With .Axes(xlCategory)
                    .Crosses = xlMaximum
                    .ReversePlotOrder = True
                End With
            End With
    '''        sngTop = sngTop + sngHeight
        Next
        
    End Sub
    Sub ChartAsSheet()
    '
    ' Macro2 Macro
    ' Macro recorded 14/10/2008 by Andy Pope
    '
        Dim rngData As Range
        Dim rngAverage As Range
        
        Set rngAverage = Sheet1.Range("A31:B31")
        For Each rngData In Sheet1.Range("A1:B30").Rows
            Charts.Add
            With ActiveChart
                .ChartType = xlBarClustered
                .SetSourceData Source:=Union(rngData, rngAverage), PlotBy:=xlColumns
                .PlotArea.Interior.ColorIndex = xlAutomatic
                .HasLegend = False
                With .Axes(xlCategory)
                    .Crosses = xlMaximum
                    .ReversePlotOrder = True
                End With
            End With
        Next
        
    End Sub

  7. #7
    Registered User
    Join Date
    09-13-2004
    Posts
    5
    Thank you! Case solved!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. adding data to diagram continuously
    By emailkia in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-17-2008, 07:25 AM
  2. Diagram doesn't update automatically?
    By Kribulin in forum Excel General
    Replies: 5
    Last Post: 06-05-2008, 05:47 AM
  3. overlap chart / venn diagram
    By kmool in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-25-2008, 06:27 PM
  4. hiding a diagram
    By tomk2005 in forum Excel General
    Replies: 2
    Last Post: 12-05-2007, 05:02 PM
  5. Tittles in column diagram
    By excelamator in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-17-2007, 05:34 AM

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