Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
133 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 53

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 27

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 27

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 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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 27

Expert Comment

by:ProfessorJimJam
ID: 40396623
Rgonzo1971  

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

Expert Comment

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

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
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…

916 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