+ Reply to Thread
Results 1 to 10 of 10

Hard coded number range into a function

  1. #1
    Registered User
    Join Date
    04-10-2009
    Location
    terr, bc
    MS-Off Ver
    Excel 2003
    Posts
    5

    Hard coded number range into a function

    Hi All,

    I'm trying to do something which is probably painfully simple but I haven't been able to find the syntax anywhere. All I need is to use the forecast function =FORECAST(I902,F832:F901,I832:I901) but want to substitute a hard coded from and to value list, such as something like =forecast(71,F832:f901,{1-70})

    That is, forecast case 71 given a range of 1 through 70. What is the correct syntax to give a from and to value? Curly brackets don't seem to work, and I don't want to do a list like {1,2,3,4,5,6,7...} which would be a pain.

    Any ideas?

    Thanks in advance for your help on this,
    Bigdavediode

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Hard coded number range into a function

    Not entirely sure I follow... not a function I use myself I confess but I think the data points of the latter range must match that of the former...

    =FORECAST(71,F832:F901,ROW(INDEX(F832:F901,0))-(ROW(F832)-1))

  3. #3
    Registered User
    Join Date
    04-10-2009
    Location
    terr, bc
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Hard coded number range into a function

    Thanks for your reply --

    Forecast accepts arrays as the last two arguments, so I'm just trying to give an array of numbers. The second input listed would give one row minus another row, giving an integer, would it not?

    I need to know how to express a series of numbers as an array: [1..70] {1..70}? I can't find the right format. Every time I search Google returns information on array functions.

    Help!

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Hard coded number range into a function

    this:

    ROW(INDEX(F832:F901,0))-(ROW(F832)-1)

    in the context of the FORECAST formula would generate an array of values {1 to 70}

    To test / prove / visualise it ... put the above into the formula bar (with = obviously) and hit F9

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

    Re: Hard coded number range into a function

    Perhaps use TREND instead, which allows you to omit the x values:

    =TREND(71, F832:F901)
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    04-10-2009
    Location
    terr, bc
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Hard coded number range into a function

    Wow, you guys are fast! Thanks again!

    Donkeyote, it's an extremely clever formula! And it works great, although I'm not sure I understand it despite reading up on index. But it does solve my problem!

    But I'm still inconsolable as I don't know how to express an array of numbers. Is it curly brackets? Square brackets?

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Hard coded number range into a function

    Re: inline array constant - you were correct at the beginning of your thread... ie: {1,2,3,4....70}

  8. #8
    Registered User
    Join Date
    04-10-2009
    Location
    terr, bc
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Hard coded number range into a function

    Donkeyote -- thanks! Is it four dots, ie {1....70} ?

    I just couldn't get that into the formula previously.

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Hard coded number range into a function

    No ... the dots were meant to represent the fact that you would need to manually type all integers from 1 through 70 into your inline array constant as you had indicated in your first post... if you could do it shorthand wouldn't we have done it ?

  10. #10
    Registered User
    Join Date
    04-10-2009
    Location
    terr, bc
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Hard coded number range into a function

    Thanks once again Donkey.

    What an odd omission from Excel!

+ 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