+ Reply to Thread
Results 1 to 12 of 12

if there are two y-axis, how to set one of them to x-axis?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    88

    Re: if there are two y-axis, how to set one of them to x-axis?

    From B80 to B197, they are non-zero values.

    Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: if there are two y-axis, how to set one of them to x-axis?

    Check the file you uploaded; it only has data to row 565, and it's all zero.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    88

    Re: if there are two y-axis, how to set one of them to x-axis?

    Hi Shg,

    Please see the attached image file from the data uploaded.

    Regards,
    Attached Images Attached Images

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: if there are two y-axis, how to set one of them to x-axis?

    Suggest you download the file you uploaded and look at it.

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: if there are two y-axis, how to set one of them to x-axis?

    In the attachement . .
    Autofiltering column-B for values greater than zero, shows B80:B197 to contains values greater than zero.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: if there are two y-axis, how to set one of them to x-axis?

    Weird.

    Add this function to the workbook.
    Private Sub dFrac(d As Double, r As Range, _
                      ByRef i As Long, ByRef dF As Double, _
                      iMatchType As Long)
        ' shg 1997-0606, 2009-0419
        '     2009-0604 added option for descending sort
    
        ' Returns an index to r in i and an interpolation fraction in dF
        ' r must be a 2+ element vector sorted a-/de-scending if iMatchType=1/-1
    
        If iMatchType = 1 And d <= r(1).Value2 Or _
           iMatchType = -1 And d >= r(1).Value2 Then
            i = 1
        Else
            i = WorksheetFunction.Match(d, r.Value2, iMatchType)
            If i = r.Count Then i = r.Count - 1
        End If
    
        dF = (d - r(i).Value2) / (r(i + 1).Value2 - r(i).Value2)
    End Sub
    
    Function LINTERP(x As Double, rX As Range, rY As Range) As Variant
        
        ' shg 1997-0606, 2009-0419
        '     2009-0604 added option for descending sort
    
        ' Linear interpolator / extrapolator
        ' Interpolates rX to return the value of y corresponding to the given x
    
        ' rX and rY must be equal-length vectors
        ' rX must be sorted ascending or decreasing
    
        Dim i       As Long     ' index to rY
        Dim dF      As Double   ' interpolation fraction
        Dim v       As Variant  ' for each/loop control variable
    
        For Each v In Array(rX, rY)
            If v.Areas.Count > 1 Then GoTo Oops
            If v.Rows.Count <> 1 And v.Columns.Count <> 1 Then GoTo Oops
            If WorksheetFunction.Count(v) <> v.Count Then GoTo Oops
        Next v
        If rX.Count < 2 Then GoTo Oops
        If rX.Count <> rY.Count Then GoTo Oops
    
        dFrac x, rX, i, dF, IIf(rX(rX.Count).Value2 > rX(1).Value2, 1, -1)
        LINTERP = rY(i).Value2 * (1 - dF) + rY(i + 1).Value2 * dF
        Exit Function
    
    Oops:
        LINTERP = CVErr(xlErrValue)
    End Function
    In C2 and copy down,

    =LINTERP(A3,$D$3:$D$337,$E$3:$E$337)

    ... then plot columns B & C

  7. #7
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    88

    Re: if there are two y-axis, how to set one of them to x-axis?

    Hi Shg,

    It works very well..

    Thank you very much..

    Regards,
    Minki

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1