Formula Question

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Formula Question

Post by BobH »

I have an Excel spreadsheet that uses the following formula in a column:
    =IF($J2<>"",$J2*($A$31-$A$2),"")

    As you can see there is an absolute reference, $A$31. Instead of this absolute reference, is it possible to write the formula such that the value in the cell in column A of the last row having a value is used?

    :cheers: :chocciebar: :thankyou:
    Bob's yer Uncle
    (1/2)(1+√5)
    Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

    User avatar
    HansV
    Administrator
    Posts: 78487
    Joined: 16 Jan 2010, 00:14
    Status: Microsoft MVP
    Location: Wageningen, The Netherlands

    Re: Formula Question

    Post by HansV »

    Try

    =IF($J2<>"",$J2*(LOOKUP(1E+307,$A:$A)-$A$2),"")
    Best wishes,
    Hans

    snb
    4StarLounger
    Posts: 575
    Joined: 14 Nov 2012, 16:06

    Re: Formula Question

    Post by snb »

    =IFERROR($J2^2*(index(A:A;counta(A:A))-$A$2)/$J2,"")

    User avatar
    BobH
    UraniumLounger
    Posts: 9284
    Joined: 13 Feb 2010, 01:27
    Location: Deep in the Heart of Texas

    Re: Formula Question

    Post by BobH »

    Hans, what does the expression (1E+307,$A:$A) mean?

    My guess is that 1E+307 is a number representing the maximum number of rows and the range expression limits it to column A. Is that anywhere close?
    Bob's yer Uncle
    (1/2)(1+√5)
    Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

    User avatar
    HansV
    Administrator
    Posts: 78487
    Joined: 16 Jan 2010, 00:14
    Status: Microsoft MVP
    Location: Wageningen, The Netherlands

    Re: Formula Question

    Post by HansV »

    1E+307 means a 1 followed by 307 zeros. Excel uses so-called scientific notation for such numbers. It is close to the largest number one can enter in an Excel cell (the largest is actually 9.99999999999999E+307).

    LOOKUP(1E+307,$A:$A) tries to look up 1E+307 in column A. It is not found, of course, and in that situation, LOOKUP returns the last number it encountered in column A.
    Best wishes,
    Hans

    User avatar
    BobH
    UraniumLounger
    Posts: 9284
    Joined: 13 Feb 2010, 01:27
    Location: Deep in the Heart of Texas

    Re: Formula Question

    Post by BobH »

    Thank you. My guess was very close. I recognized the scientific notation and incorrectly conflated the number with the maximum rows Excel can have.

    Thanks again. :wine:
    Bob's yer Uncle
    (1/2)(1+√5)
    Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs