+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Specify Range given a column number

  1. #1
    Registered User
    Join Date
    12-17-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Unhappy Specify Range given a column number

    I have a spreadsheet that displays a graph of earnings.

    I have columns labeled by month, and each row represents a different product. For example, I have a row for Product A, that has revenue numbers for each month, up to the current month. Right under that is the row for Product B. Under those, is a monthly total, which is the sum of product A and product B for that month.

    We'll pretend A1 is "January" and L1 is "December".

    So, in my graph, I have a data label range that I manually set going from A1:L1 -- that is, every month of the year, ending at the current month, which is December.

    Next month, I'll want the graph to go from A1:M1 -- from Jan 2009 to Jan 2010.

    I already have a cell which contains the month column as an integer: =MONTH(NOW())+(12*(YEAR(NOW())-2009))

    So it's the current month of the year plus 12 times the number of years that the data goes back, which in my case is only 1 -- so right now, that formula returns "12" since it's the 12th month of the first year. Next month it'll return "13."

    I already know how to get a total value for the current month. For example, if I want to reference the total for the current month, and the "total" row is row 4, and the month cell is A5, I'd say:

    =INDEX(A4:ZZ4,1,A5) [actually, I'd like that to just select all of row 4, but I don't know how]

    That gives me the value for the total in the current month.

    Now, in the graph I want the range to go from the beginning of time, (ie Jan 2009) to the present month, whatever month that is. I want the present month to automatically be set, I don't want to edit the range to add one more column every month.

    For the graph range I tried:

    A4:INDEX(A4:ZZ4,1,A5)

    But that doesn't work because the INDEX function is returning the value of the cell, not the cell itself. How can I return the cell itself, so I can specify a range that updates dynamically depending on the month?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Specify Range given a column number

    Search the forum for dynamic named ranges. There are many examples and links to sites explaning how to make your chart series move with the data.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    12-17-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Specify Range given a column number

    Thanks for the lead Andy!

    I'm still having a bunch of trouble.

    I've tried these:

    1) In the Horizontal Axis Labels Range I tried:

    =OFFSET(Overview!B$1,1,Charts!$S$3)

    Where Overview!B1 is "January," and the column number is Charts!S1 -- that gives me an error about the function being invalid.

    2) Next I tried creating a named range with the following formula:

    =OFFSET(Overview!B$1,1,Charts!$S$3)

    Which didn't give an error, but also didn't select the range in the manager the values read "{...}"

    3) So, I thought maybe I just don't understand what the OFFSET returns. I think it returns a range, but maybe it only returns a cell, so I tried:

    =Overview!B1:OFFSET(Overview!B$1,1,Charts!$S$3)

    But that also gives a range value of "{...}"



    Also, for each of those above, I tried specifying 0,0 for the rows and cols, and putting inputting width and height instead. That gave identical results.

    I'm stumped...

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

    Re: Specify Range given a column number

    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  5. #5
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Specify Range given a column number

    I'm guessing here - the following formula (or some variation of it) for your dynamic range in the name manager might give you the range of used data:

    Please Login or Register  to view this content.
    Excel 365 user. To unblock a downloaded macro-enabled workbook, go to your "Downloads" folder > right click on the workbook name > click 'Properties' > check the 'Unblock' checkbox. You can now open the workbook.

+ 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