+ Reply to Thread
Results 1 to 9 of 9

Dynamic Range Query

  1. #1
    Registered User
    Join Date
    07-30-2010
    Location
    Warrington, England
    MS-Off Ver
    Excel 2010
    Posts
    71

    Question Dynamic Range Query

    I'm looking to set up a dynamic range that spans the range C5:G20 on a sheet. Additional rows of data will be added hence the requirement for the dynamic range. I've established that I can create a dynamic range for one column (C) but I'm struggling to set this up for the required area of the spreadsheet. I'd be grateful of any help

    Here's the code I have at the moment

    Please Login or Register  to view this content.
    Many thanks in advance

    M

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Dynamic Range Query

    What's in C1 to C4 and are there any gaps in column C?

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Dynamic Range Query

    Assuming C1 to C4 are blank and there are no gaps:

    =sheet1!$c$5:index(sheet1!$g:$g,counta(sheet1!$c:$c)+4)

    Regards, TMS

  4. #4
    Registered User
    Join Date
    07-30-2010
    Location
    Warrington, England
    MS-Off Ver
    Excel 2010
    Posts
    71

    Question Re: Dynamic Range Query

    Many thanks for your help TMS. I've taken your code, modified it slightly to reflect actual columns on my worksheet but i'm not sure that it's working. The aim of the code is to list all the worksheets in a workbook, identify which ones are hidden/protected and list them on the worksheet. The code works if I define a range in code the usual way but not when adopting the dynamic range approach. Heres the code

    Please Login or Register  to view this content.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Dynamic Range Query

    Your real world code seems to bear little relation to the example you posted

    However, I can't see anything obviously wrong with what you have.

    My equivalent code would be:

    Please Login or Register  to view this content.


    Have a look at what your range really is:

    Insert | Name | Define... | Select the range | tab into the Refers to field. That should highlight the range specified. Check that's what you think it is.


    Regards, TMS

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Dynamic Range Query

    Hi Mike_e

    I've only "looked" at your code and believe this line needs to be modified
    Please Login or Register  to view this content.
    like so
    Please Login or Register  to view this content.
    Notice the single quotes around 'F-Log Info' (the name has spaces and so needs delimited)
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Dynamic Range Query

    @jaslake: good spot

  8. #8
    Registered User
    Join Date
    07-30-2010
    Location
    Warrington, England
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Dynamic Range Query

    Hi TMS, all sorted. I was missing the ' before and after the sheet name in the formula. Many thanks again for your help, I've been putting this off for a while because of this issue...onwards and upwards now!!

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Dynamic Range Query

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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