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
130 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:Mohammed Dallag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 52

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:Mohammed Dallag
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 26

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 26

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
 
LVL 52

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 26

Expert Comment

by:ProfessorJimJam
ID: 40396623
Rgonzo1971  

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

Expert Comment

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

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:Mohammed Dallag
ID: 40398308
Thank you so much for the help
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

630 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