+ Reply to Thread
Results 1 to 8 of 8

Use a function as the starting cell of a range

  1. #1
    Registered User
    Join Date
    06-16-2010
    Location
    Baltimore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Question Use a function as the starting cell of a range

    Hello all:

    I'm trying to use a range in a function, but the starting cell of the range should be changed under different circumstances. How can I do it?

    For example:
    I have: =-Nth_Occurrence('JULY BW Summary'!$A171:$H1000,"Result",1,0,4) in the cell. I want to replace the number 171 with a function that returns this number.

    I've been trying by putting quotes and parentheses at different places but it didn't work.

    BTW, Nth_Occurrence is a macro that I have in my worksheet.


    I appreciate any idea on this.

    Thanks.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,730

    Re: Use a function as the starting cell of a range

    You could use INDEX, e.g.

    INDEX('JULY BW Summary'!$A1:$A1000,FUNC):$H1000

    where FUNC is your function that return 171
    Audere est facere

  3. #3
    Registered User
    Join Date
    06-16-2010
    Location
    Baltimore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Use a function as the starting cell of a range

    Quote Originally Posted by daddylonglegs View Post
    You could use INDEX, e.g.

    INDEX('JULY BW Summary'!$A1:$A1000,FUNC):$H1000

    where FUNC is your function that return 171
    daddylonglegs, are you suggesting to plug the index formula into my function like this:
    =-Nth_Occurrence(INDEX('JULY BW Summary'!$A1:$A1000,FUNC):$H1000,"Result",1,0,4)

    I just tried it but it turns an error value message back to me.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,730

    Re: Use a function as the starting cell of a range

    I thought you had a function that returned 171, you need to put that in place of FUNC, or just put 171 in there

    =-Nth_Occurrence(INDEX('JULY BW Summary'!$A1:$A1000,171):$H1000,"Result",1,0,4)

  5. #5
    Registered User
    Join Date
    06-16-2010
    Location
    Baltimore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Use a function as the starting cell of a range

    Hi, daddylonglegs.

    Yes I did put the function in the INDEX formula but it didn't work.
    It's working when I put: =-Nth_Occurrence('JULY BW Summary'!$A171:$H1000,"Result",1,0,4)

    Will it have anything to do with the format of the reference?

    Thank you.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,730

    Re: Use a function as the starting cell of a range

    Apologies, you need the sheet name in the second part of the reference, i.e.

    =-Nth_Occurrence(INDEX('JULY BW Summary'!$A1:$A1000,171):'JULY BW Summary'!$H1000,"Result",1,0,4)

  7. #7
    Registered User
    Join Date
    06-16-2010
    Location
    Baltimore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Use a function as the starting cell of a range

    WOW!!

    It's working great now. Thank you so much for your help.

  8. #8
    Registered User
    Join Date
    06-16-2010
    Location
    Baltimore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Use a function as the starting cell of a range

    Hi daddylonglegs.

    Would you please do me another favor to take a look at this problem? I'm using a function as following:
    =MATCH(C11,'JULY BW Summary'!$B:$B,0)

    I want to replace JULY with a function I have that gives me different months. How shall I do it? I have tried several ways to put quote and & at different places but they all didn't work.

+ 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