Consulting

Results 1 to 8 of 8

Thread: Creating dynamic Range for combobox

  1. #1
    VBAX Regular
    Joined
    Aug 2006
    Posts
    17
    Location

    Question Creating dynamic Range for combobox

    I have a combo box on a worksheet named "Dashboard" which draws its fields from a range on a "Wardinfo" sheet. The list of wards will grow as wards enter data but until then I want the combobox list to only display wards which have already entered data.

    I wanted to create a dynamic range which would then populate the combobox. Using the dynamic range code selects the range but the subsequent code ignores it. Only if I use the "Create range in Top row" manually does it work. Is there anyway to do this in vba allowing it to be a dynamic range?

    Have uploaded where I am at incase my explanation doesn't make sense.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Specify what you mean by '... the subsequent code ignores it.'
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Aug 2006
    Posts
    17
    Location
    The Code in the Worksheet "support" for the range selWard

    =OFFSET(INDIRECT(selRegion),resSelWard-1,0,1,1)

    comes back with an invalid cell reference error if I use the dynamic range whereas it works perfectly with the "Create range in Top row" method.

    Don't fully understand the coding here as I am newbie and was tasked to try to make the whole thing more dynamic so I am learning as I go ahead.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I still don't know what your problem is. The formula in Support only asks for one value, you get one value. Change the number, you get a different value.

    And what is the "Create range in Top row" method?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Aug 2006
    Posts
    17
    Location
    if you go to Insert->name->create you get Create names in: Top row,or Left column etc.

    By hightlighting your list including the range name and then choosing Top row, the range is named exactly like the Top of the lists text.

    I used this method for defining ranges for RVH , BCH

    I have tried a different method for MIH and BHSCT which should allow dynamic ranges using =WardInfo!$K$3:INDEX(WardInfo!$K:$K,COUNTA(WardInfo!$K:$K)) where K is the column for BHSCT and K3 is the starting cell for the options.

    If you now go to the Dashboard Worksheet and Select RVH or BCH and then a ward the code works, if however you choose MIH or BHSCT and then a ward there is an error.
    I have uploaded the revised workbook with both options in.

    Hope this is bit clearer

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I don't get the error. I got a pivot error for Other, because there are no wrads, but none ofthe others.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Regular
    Joined
    Aug 2006
    Posts
    17
    Location
    I have ask 4 other colleagues to test this on their PC's / Laptops and they all receive the same error as myself. We are using both Office XP in Xp and Office 2007 in Vista. If you choose RVH or BCH the selected hospital changes the graph, however if you choose BHSCT or MIH the list populates but on choosing a hospital you get an error stating Runtime error 13 (in Office 2007) or 1004 (Unable to set the _default property of the PivotItem class (in XP)
    Thanks

  8. #8
    VBAX Newbie
    Joined
    Jun 2010
    Posts
    3
    Location
    The columns & Counting thread I started might help with your create names issue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •