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
122 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 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,

You could use

XY Chart Labeller

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

Regards
0
 

Author Comment

by:dallagmm
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
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
Comment Utility
Rgonzo1971  

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

Expert Comment

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

Expert Comment

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

Author Closing Comment

by:dallagmm
Comment Utility
Thank you so much for the help
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
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 view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

771 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

12 Experts available now in Live!

Get 1:1 Help Now