Solved

I have x and y plot in excel  and I need to display on top of each point in the plot a third value (z)

Posted on 2014-10-22
9
126 Views
Last Modified: 2014-10-22
I have x and y plot in excel  and I need to display on top of each point in the plot a third value (z). In my attached example the third column is called well name. How can I display the well Name on top of each point in the plot.
EE-Proj3.xlsm
0
Comment
Question by:dallagmm
  • 4
  • 3
  • 2
9 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 40396342
Hi,

You could use

XY Chart Labeller

http://www.appspro.com/Utilities/ChartLabeler.htm

Regards
0
 

Author Comment

by:dallagmm
ID: 40396369
can't install any utility in my company system. I appreciate if you can modify the attached script to do that.
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40396557
here download it from this link below in the xlam version does not require admin password


http://1drv.ms/12af4k7
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40396574
if you do not want the tool and you just want your file to be added with the required label then here it is please find attached.
EE-Proj3.xlsm
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40396621
Hi,

pls try

Option Explicit
Sub Prepare_Well_Data()
    Dim rngInput, rngMRC As Range
    Dim cl As Object
    Dim strChartName As String
    Dim lngInputRows As Long
    Dim intSeries As Integer
    Dim r1, r2 As Long
    Dim x, doit As Integer
    Dim Adr, rng, Idx
    
    Application.DisplayAlerts = False
    
    For x = 1 To ActiveWorkbook.Sheets.Count
        If Sheets(x).Name = "Results" Then
            doit = MsgBox("Do you want to replace the existing Results sheet?", vbExclamation + vbYesNo, "Results Sheet")
            If doit = vbYes Then
                Sheets("Results").Delete
            Else
                Exit Sub
            End If
        End If
    Next x
    
    Sheets("Sheet1").Select
    Sheets("Sheet1").Copy after:=Sheets("Sheet1")
    ActiveSheet.Name = "Results"

    Application.ScreenUpdating = False
    lngInputRows = Range("A1").End(xlDown).Row
    Set rngInput = Range("A1:D" & lngInputRows)
    Range("A1").Value = "Name"
    Range("B1").Value = "GOR"
    Range("C1").Value = "Oil"
    
    'Sort well data
    ActiveWorkbook.Worksheets("Results").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Results").Sort.SortFields.Add Key:=Range("D2:D" & lngInputRows) _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets("Results").Sort.SortFields.Add Key:=Range("B2:B" & lngInputRows) _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Results").Sort
        .SetRange rngInput
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
    'add cumulative formulas
    Range("E1").Value = "GOR Cumulative"
    Range("F1").Value = "Oil Cumulative"
    Range("E2").Select
    ActiveCell.Formula = "=B2+IF($D2<>$D1,0,E1)"
    Range("F2").Formula = "=C2+IF($D2<>$D1,0,F1)"
    Range("E2:F2").Copy
    Range("E3:F" & lngInputRows).PasteSpecial
    Application.CutCopyMode = False
    Range("E2:F" & lngInputRows).NumberFormat = "0.00"
    Columns("A:F").AutoFit
    
    'Chart data by MRC_Group
    Set rngMRC = Range("D2:D" & lngInputRows + 1)
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlXYScatterSmooth
    strChartName = Mid(ActiveChart.Name, InStr(1, ActiveChart.Name, " ", vbTextCompare) + 1, 40)
    r1 = 2: r2 = 2: intSeries = 1
    For Each cl In rngMRC
        If cl.Value <> cl.Offset(1, 0).Value Then 'create new series
            ActiveSheet.ChartObjects(strChartName).Activate
            ActiveChart.SeriesCollection(intSeries).Select
            ActiveChart.SeriesCollection(intSeries).Name = "=Results!$D$" & r1
            ActiveChart.SeriesCollection(intSeries).XValues = "=Results!$E$" & r1 & ":$E$" & r2
            ActiveChart.SeriesCollection(intSeries).Values = "=Results!$F$" & r1 & ":$F$" & r2
            ActiveChart.SeriesCollection(intSeries).ApplyDataLabels
            ActiveChart.SeriesCollection(intSeries).DataLabels.Select
            Selection.Position = xlLabelPositionAbove
            Adr = Split(ActiveChart.SeriesCollection(intSeries).Formula, ",")
            Set rng = Range(Adr(1)).Offset(0, -4)
            For Idx = 1 To rng.Count
                ActiveChart.SeriesCollection(intSeries).Points(Idx).DataLabel.Text = rng.Offset(Idx - 1).Resize(1)
            Next
            r1 = cl.Row + 1
            intSeries = intSeries + 1
        End If
        r2 = r2 + 1
    Next cl
    ActiveChart.SetElement (msoElementLegendTop)
    ActiveChart.ChartArea.Select
    With ActiveSheet.Shapes(strChartName)
        .Top = 20
        .Left = 400
        .Height = 300
        .Width = 500
    End With
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
End Sub

Open in new window

Regards
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40396623
Rgonzo1971  

you are fast !   how could you write the code this fast?
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 40396637
I just added 9 lines to the code in the file itself
0
 
LVL 25

Expert Comment

by:ProfessorJimJam
ID: 40396678
Hmm,  i did not check the file that it had already codes in it.
0
 

Author Closing Comment

by:dallagmm
ID: 40398308
Thank you so much for the help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro to determine Text Replacement 17 38
Help with excell ... 6 58
Problem to With line 4 36
Excel 2010 Text Formatting placing a hyphen in front of text 3 20
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now