+ Reply to Thread
Results 1 to 16 of 16

How to update (automatically) the range of a Defined name range

  1. #1
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    How to update (automatically) the range of a Defined name range

    Need help!

    I am looking for a Macro that will allow me to update the range of a Defined name range such as every time I add a name into the list, the only thing I will be doing is passing the client name and the list of client will be automatically updated and my drop down ListBox will show the new client name, which can be selected by the user.

    Thank you in advance for your help.

    Chuck

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Not sure I know what you mean.

    To update a list from A2 to the first empty cell down:
    Please Login or Register  to view this content.

    If I want to update a named range from E2 to the last cell with a value:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-09-2007
    Posts
    79
    Hi Kenneth,

    Let me thank you first for taking the time to reply to my request but this is not exactly what I am looking for. Let me try to explain:

    I have Data validation list which range from let us say D100:D200, whose Defined name range is named SupplierList. Now when the user click on the Dropdown list, which is created originally using the Data Validation List and the Supplier is not listed, whatever the user enter will be added to the list of supplier and therefore the range will no longer be D100:D200 but D100:D201, which will be reflected in the Defined Name range called SupplierList with the new range.

    Does this makes more sense?

    Thanks again.

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    What cell(s) would the data be entered? A data validation would fail if the entry does not exist. Maybe a combobox would be a better option? We could do it with a combobox.

  5. #5
    Registered User
    Join Date
    07-09-2007
    Posts
    79
    Then let us use a combo box instead. I will do the necessary changes to use the ComboBox instead, but will need the programming behind the scene that will do the necessary update. I will need the routine that will apply the update when I enter into the Combo Box a new Supplier, which will also update the SupplierList Defined range Name and its range. Thanks for your help.
    Last edited by chamdan; 10-28-2008 at 08:17 PM. Reason: Clarifying the objective

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you use a Dynamic Named Range the range will expand as data is entered. See

    http://www.cpearson.com/excel/named.htm
    Last edited by royUK; 10-29-2008 at 05:26 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    Entry into ComboBox to update the Define Name Range

    Thanks RoyUK and Kenneth, I have enclosed here an example so you may understand what I am trying to do. This is something similar to what I am trying to do.

    Regards,

    Chuck
    Attached Files Attached Files

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Use a Dynamic named Range as I said before

  9. #9
    Registered User
    Join Date
    07-09-2007
    Posts
    79
    Sorry RoyUK, I could not figure out how to make it work. I have checked the example from the link you sent me but could not figure out how to put it together so it can work. I am not an expert in Excel just basic knowledge so bear with me. Would you mind making the necessary update to the spreadsheet I enclosed earlier so I can see how you would do it to work. I could not enter and new value into the combo box and update the range list. Every time I enter a value and try to press <Enter> nothing happens.

    Thanks in advance.

    Chuck

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480
    Dynamic named ranges do not work well with Acitve Controls.

    Use the Define names dialog to alter the SupNames range to

    =OFFSET(Sheet1!$A$30,0,0,COUNTA(Sheet1!$A:$A)-1,1)

    If you save, close and reopen the workbook the dropdown list will match.

    Add new items or remove existing ones and the control will not update correctly.

    If you use the built-in data validation with SupNames as the list source it will be dynamic.
    Cheers
    Andy
    www.andypope.info

  11. #11
    Registered User
    Join Date
    07-09-2007
    Posts
    79
    Hi Andy,

    Thanks for your help but this works fine if you update the Range Name but I am wondering if from the Active Control (Combo Box) you can enter a value and this value will be added to the Range. I tried and tried and tried but will not work.

    Thanks,
    Chuck

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480
    You would need to code against the comboboxes events in order to add new items to the sheet.

    If you do that then I think that simply updating the ListFillRange will keep the combobox and list in sync.

    So, set the Listfillrange to A30:A39, or what ever the current range of the list is.
    Then add this code to the comboboxes event

    Please Login or Register  to view this content.

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Is this what you want? I have added the Dynamic Named Range and some code. If you type into the combobox then exit it by clicking a cell the contents are added

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by royUK; 10-29-2008 at 01:09 PM.

  14. #14
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    Thumbs up [QUOTE]<B> Solved<B/>[/QUOTE]

    Excellent! This is exactly what I wanted Andy. But now, every time I enter a value my value is added at the very last address of the range and therefore leaving blank rows in between. It should find the last non blank cell and add afterward the new one. Otherwise, This is exactly what I am looking for.

    Thanks to all.

    Chuck
    Last edited by chamdan; 10-29-2008 at 01:29 PM. Reason: Solved

  15. #15
    Registered User
    Join Date
    07-09-2007
    Posts
    79

    Thumbs up Solved

    Thank Andy!

    It works perfectly and I have added a sort section to it to list in alphabetic order the list found within the range.

    Thank you again.
    Chuck

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    chamdan, for the future:

    To mark a thread as solved:

    Click the Edit button on your first post in the thread

    Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes

    If more than two days have elapsed since your first post, ask a moderator to mark it.
    Entia non sunt multiplicanda sine necessitate

+ 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