+ Reply to Thread
Results 1 to 9 of 9

Offset+counta to autoselect data range for charting purposes

  1. #1
    Registered User
    Join Date
    11-12-2013
    Location
    Geneva
    MS-Off Ver
    Excel 2007
    Posts
    59

    Offset+counta to autoselect data range for charting purposes

    Hi community!

    I have learned how to play with data ranges and define names for charts to automatically update them by using the formula offset + counta. An example would be: =OFFSET(Sheet1!$B$7,0,0,COUNTA(Sheet1!$B$6:$B$37)-1).

    So, the problem comes when there is a need to select a data range which is not that well defined like $B$6:$B$37. So, I need to import data regularly into my workbook, this data will be imported right below of the last cell with values.

    Now, how would I manage to automatically select the data range from this new import for my chart? See attached example. I have highlighted in Yellow a potential import... Please note there is no data in there so feel freel to fill it with any numbers you like.

    I have tried to use a vlookup to find Country+Programme+Year (cat1 in the example) in the 'counta' part of the formula above. But I get lost,as a vlookup would retrieve a value and would not be useful for the data range?

    Thanks a lot for your help! Really appreciate it.

    All the best from my side to you all for Xmas time
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    11-12-2013
    Location
    Geneva
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: Offset+counta to autoselect data range for charting purposes

    So according to the attachement "Book2", I would want to set the data source in the offset formula (avobe) for my chart as follows:

    AB2:AB9 and AB26 and AB27 as they match with the values in country column: Zimbabwe, Programme and Year.

    Hope you can help me with this.

    Cheers

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

    Re: Offset+counta to autoselect data range for charting purposes

    it would have helped if you include a chart example so we can see what output looks like.

    have you considered pivot table/chart? Especially because of the non contiguous ranges
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    11-12-2013
    Location
    Geneva
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: Offset+counta to autoselect data range for charting purposes

    You are right, but as I don't know how to generate the chart, I have tweaked it with Paint. So you can see how output would be.

    I have also tried the pivot chart, but it does not make the job to automatically update the chart?? I have made a few tests and cannot find the way to make it work.

    So that's why the point of the formula. Any idea?


    Many thanks!
    Attached Files Attached Files

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

    Re: Offset+counta to autoselect data range for charting purposes

    I've used a named range for the pivot table data source.
    You will need to refresh the table once new records have been added. But it handles non contiguous records.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-12-2013
    Location
    Geneva
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: Offset+counta to autoselect data range for charting purposes

    Hi Andy,

    Thanks for your help! However and as you may know the potentials of the pivot charting is quite limited. That's why I was looking for the 'formula' way to achieve 'the same' but with the regular charting features.

    Any idea how to achieve this with the formula??

    All the best,

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

    Re: Offset+counta to autoselect data range for charting purposes

    You would need to build a contiguous range of data in order to chart using formula.

    You could always build your own chart based on the pivot table output

  8. #8
    Registered User
    Join Date
    11-12-2013
    Location
    Geneva
    MS-Off Ver
    Excel 2007
    Posts
    59

    Re: Offset+counta to autoselect data range for charting purposes

    Hi Andy,

    Thanks a lot for replying!

    What do you mean by "build contiguous range of data"?

    The main problem with the chart out of the pivot table is that it won't get updated when the pivot does.

    There is no way around or solution to do this with the offset+count formula?

    THanks!!!

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

    Re: Offset+counta to autoselect data range for charting purposes

    Cells in a single block.

    A1:A3 is contiguous
    A1,A3 is non-contiguous

    You can use event code to update chart when table updates

    This event within the sheet object
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] +OFFSET and COUNTA in VBA
    By Baphomay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2013, 08:11 PM
  2. Data validation, IF, OFFSET & COUNTA
    By alfgrey in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-24-2013, 08:27 PM
  3. autoselect a range with text
    By studioturnhout in forum Excel General
    Replies: 1
    Last Post: 07-28-2013, 10:52 AM
  4. Autoselect data using Macros
    By shoaibj@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-02-2006, 01:35 PM
  5. Defining maximum value from a named range for charting purposes
    By Barb Reinhardt in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-08-2006, 12:15 PM

Tags for this Thread

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