[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Excel > autogenerate graph

Asked by srmrenault in Microsoft Office Suite

Tags: graph

I have written a couple of macros which more or less work, but not automatically. The result (a graph) is okay, but the data used to create this graph must be selected based on what the user types in a textbox of a userform.

Sub Analyse_Einzeln()
' this macro doesn't look up the SupplierNr
' this macro doesn't take into account the number of Periods the user
' wants to see... I manually selected the data :(
        ' in this example
        ' Sheet ArtikelData contains the imported TXT files
        ' row 2 contains the SupplierNr
        ' row 4 contains the Amount
        ' row 5 contains the Purchasing_Value
        ' row 7 contains the Intermediary_Value
        ' row 8 contains the EndConsumer_Value
        '
        ' however, in the REAL macro, these rows should depend on
        ' the last column that is filled with data
        ' the row in which the SupplierNr is found
        ' Row 4 would be Row(SupplierNr)+2
        ' Row 5 would be Row(SupplierNr)+3
        ' so
        ' instead of B4:E7, the selection should be 'LastColumn-Period''RowSupplierNr+2:'LastColumn''RowSupplierNr+5'
        ' where LastColumn is the last column that is filled in the ArtData sheet
           ' this can be checked by looking in row 1, where the dates that the TXT file is imported are located
        ' where RowSupplierNr is the row in which the specified SupplierNr is found
        ' where Period is the number of periods specified in the form by the user
        ' info from Userform: SupplierNr and #Periods

    Charts.Add
    ActiveChart.SetSourceData Source:=Sheets("ImportData").Range("B4:E7"), _
        PlotBy:=xlRows
        ' for the Range, see the comments above...
        ' here we are setting the type of lines/bars for the chart
   
    ActiveChart.SeriesCollection(1).XValues = "=ImportData!R1C2:R1C5"
    ActiveChart.SeriesCollection(1).Name = "=""Amount"""
    ActiveChart.SeriesCollection(1).AxisGroup = 2
    ActiveChart.SeriesCollection(1).ChartType = xlColumnClustered
   
    ActiveChart.SeriesCollection(2).XValues = "=ImportData!R1C2:R1C5"
    ActiveChart.SeriesCollection(2).Name = "=""Purchasing Value (MPDU)"""
    ActiveChart.SeriesCollection(2).AxisGroup = 1
    ActiveChart.SeriesCollection(2).ChartType = xlLineMarkers
   
    ActiveChart.SeriesCollection(3).Name = "=""Sales Value 1 (Netto)"""
    ActiveChart.SeriesCollection(3).AxisGroup = 1
    ActiveChart.SeriesCollection(3).ChartType = xlLineMarkers
   
    ActiveChart.SeriesCollection(4).Name = "=""Sales value 2 (Brutto)"""
    ActiveChart.SeriesCollection(4).AxisGroup = 1
    ActiveChart.SeriesCollection(4).ChartType = xlLineMarkers
               
    ActiveChart.Location Where:=xlLocationAsNewSheet
    ActiveChart.Name = Format("SupplierNr") & ("_") & ("Period") & ("_") & (Date)
    ' as you can see, the newly generated Sheet is not named correctly yet...
    ' the name should be 'SupplierNr'_'Period'_'DD-MM-YYYY'
    ' where SupplierNr is the SupplierNr specified in the form by the user
    ' where Period is the number of periods specified in the form by the user
        ' these two don't work yet
    ' where DD-MM-YYYY is the current date

    With ActiveChart
        .HasTitle = True
        .ChartTitle.Characters.Text = "Supplier Name"
        ' in this example I manually entered the Title
        ' in the real macro, the Title should be automatically generated
        ' the Supplier Name can be found directly under the SupplierNr in the same column.
       
        .Axes(xlCategory, xlPrimary).HasTitle = True
        .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
        .Axes(xlValue, xlPrimary).HasTitle = True
        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Wert (EUR)"
        ' SeriesCollection (2),(3) and (4) depend on xlValue, xlPrimary
        .Axes(xlValue, xlSecondary).HasTitle = True
        .Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Amount"
        ' SeriesCollection (1) depends on xlValue, xlSecondary
        .Axes(xlValue).HasMajorGridlines = True
        .ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
        ' here, I labeled the axis of the chart
    End With
           
    With ActiveChart.SeriesCollection(1).DataLabels.Select
    ActiveChart.SeriesCollection(1).Points(1).DataLabel.Select
    Selection.Top = 320
    ActiveChart.SeriesCollection(1).Points(2).DataLabel.Select
    Selection.Top = 320
    ActiveChart.SeriesCollection(1).Points(3).DataLabel.Select
    Selection.Top = 320
    ActiveChart.SeriesCollection(1).Points(4).DataLabel.Select
    Selection.Top = 320
    End With
    ' here, I move the DataLabels of the Amounts to halfway the Columns
    ' which they represent
    ' however, this way of moving is not so beautiful since I believe that
    ' when the size of the columns is different, they may no longer
    ' be on the right spot
    ' it would be better to take the existing position of the DataLabel
    ' and from there move it 30 (points, pixels??) lower (or 20% lower, depending on the height of the column)
    ' besides the moving, another thing is important
    ' here we are dealing with 4 Points, but when we generate a graph
    ' with 6 Periods, there should be 6 Points to move...
    ' the best solution would be to automatically select ALL
    ' Points in the SeriesCollection(4).DataLabels
    ' and then move them ALL automatically
   
    ActiveChart.SeriesCollection(2).Select
    With Selection.Border
        .ColorIndex = 9
        .Weight = xlThick
        ' .MarkerBackgroundColorIndex = 2
        ' .MarkerForegroundColorIndex = 9
    End With
   
    ActiveChart.SeriesCollection(3).Select
    With Selection.Border
        .ColorIndex = 6
        .Weight = xlThick
        ' .MarkerBackgroundColorIndex = 2
        ' .MarkerForegroundColorIndex = 6
    End With
   
    ActiveChart.SeriesCollection(4).Select
    With Selection.Border
        .ColorIndex = 7
        .Weight = xlThick
        ' .MarkerBackgroundColorIndex = 2
        ' .MarkerForegroundColorIndex = 7
    End With
    ' changing the style of the lines, for better viewability when printing
End Sub

************************************************
Second Macro, mostly the same problems:
************************************************

Sub Analyse_Mehrere()

' Analysis of several suppliers
' the goals is to compare the purchasing value of 3 different suppliers by entering the
' supplier numbers and the number of periods

    Charts.Add
    ActiveChart.ChartType = xl3DColumnStacked100
    ActiveChart.SetSourceData Source:=Sheets("ImportData").Range( _
        "B5:E5,B13:E13,B21:E21"), PlotBy:=xlRows
        ' again, the range should be automatically selected by the specified SupplierNr and
        ' #Periods from the Userform.
        ' Row 5 contains the Purchasing Value of Supplier1
        ' Row 13 contains the Purchasing Value of Supplier2
        ' Row 21 contains the Purchasing Value of Supplier3
    ActiveChart.SeriesCollection(1).XValues = "=ImportData!R1C2:R1C5"
    ActiveChart.SeriesCollection(1).Name = "=""SupplierNr1"""
    ActiveChart.SeriesCollection(2).XValues = "=ImportData!R1C2:R1C5"
    ActiveChart.SeriesCollection(2).Name = "=""SupplierNr2"""
    ActiveChart.SeriesCollection(3).XValues = "=ImportData!R1C2:R1C5"
    ActiveChart.SeriesCollection(3).Name = "=""SupplierNr5"""
    ActiveChart.Location Where:=xlLocationAsNewSheet
    ActiveChart.Name = ("1") & ("_") & ("2") & ("_") & ("5") & ("_") & Format(Date)
    ' as you can see, the newly generated Sheet is not named correctly yet...
    ' the name should be 'SupplierNr1'_'SupplierNr2'_'SupplierNr3'_'DD-MM-YYYY'
    ' where SupplierNr are the SupplierNrs specified in the form by the user
    ' where DD-MM-YYYY is the current date
   
    With ActiveChart
        .HasTitle = True
        .ChartTitle.Characters.Text = "Vergleich mehrere Lieferanten"
        .Axes(xlCategory).HasTitle = True
        .Axes(xlCategory).AxisTitle.Characters.Text = "Datum"
        .Axes(xlValue).HasTitle = True
        .Axes(xlValue).AxisTitle.Characters.Text = "% von PDU-Total"
        .Axes(xlValue).AxisTitle.Orientation = xlUpward
    End With
           
    ActiveChart.HasLegend = True
    ActiveChart.Legend.Select
    Selection.Position = xlBottom
    ActiveChart.HasDataTable = False
   
End Sub

So what we are trying to do is in fact lookup a (one or more) suppliernumber in the last filled column. The suppliernumbers are located in every 8th row (starting on row 3).  It is possible that in a certain month, suppliernr X doesn't exist. In that case, there must be an errormessage which says something like 'Supplier does not exist in this month'. It would be ideal when the macro then automatically looks in the previous column.

Please let me know if you need some more info...

Thanks for your help,

Wout
[+][-]07/07/03 04:09 AM, ID: 8868383Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/07/03 04:28 AM, ID: 8868531Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/07/03 04:29 AM, ID: 8868533Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/09/03 05:42 AM, ID: 8884792Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/09/03 06:48 AM, ID: 8885324Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/14/03 01:15 AM, ID: 8915300Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/14/03 01:45 AM, ID: 8915414Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/15/03 03:06 AM, ID: 8924016Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/22/03 08:30 AM, ID: 8977544Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/23/03 01:00 AM, ID: 8984038Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/23/03 01:01 AM, ID: 8984050Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/23/03 09:13 AM, ID: 8987598Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/25/03 12:33 PM, ID: 9007484Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Office Suite
Tags: graph
Sign Up Now!
Solution Provided By: smozgur
Participating Experts: 2
Solution Grade: A
 
[+][-]07/28/03 02:05 AM, ID: 9018262Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/28/03 02:09 AM, ID: 9018282Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/28/03 02:56 AM, ID: 9018461Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81