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
127 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
  • 4
  • 3
  • 2
9 Comments
 
LVL 50

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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 50

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 50

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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