+ Reply to Thread
Results 1 to 16 of 16

VB to activate list drop-down boxes when data is entered in a cell

  1. #1
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    VB to activate list drop-down boxes when data is entered in a cell

    Hello all.
    I have a Validation drop down box (column B) and a defined range drop down box (column E linked to the Totals tab with A2-A31 defined as Products) that I need to activate everytime data is added to a new line in column 'A' and cells in column 'B' or 'E' are selected. Additionally, they need to activate if the cells in column 'B' or 'E' are selected for any of the old data so changes can be made. This will help reduce the overall file size and calculation time for a year's worth of data.

    There is already some code on the worksheet that looks like it can be adapted if someone knows how to code in the drop down boxes.

    Thanks in advance for your assistance!!!

    Andrew
    Attached Files Attached Files
    Last edited by drewship; 05-22-2009 at 12:01 PM.

  2. #2
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    All, I recorded a macro and adapted the Worksheet code to include the recorded macro. This will activate the Status dropdown only when data is in column 'A'. Going to try the same thing for the defined list.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    The Named Range drop down is more difficult than I thought. I can not seem to get it recorded so the actual drop down appears. Can anyone assist?

    Also, I need some code to automatically clear data and drop down boxes from any row that has no data in column 'A'. Currently, if I delete data in column 'A', the Status drop down box still appears and I have to delete the rest of the data manually. The drop down box can not be deleted but must be overwritten with an unformatted cell.

    Any help is appreciated!!

    Andrew

  4. #4
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Bump, no response

  5. #5
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Hello all. I am having problems working out the code for the Named Range drop down.

    After perusing the forum I found the attached workbook that looks like it might do what I am looking for. The problem is the code refers to OLEObjects which I know nothing about and am not sure I need.

    Can someone help me adapt this code:

    Please Login or Register  to view this content.
    which works in the 'drop downs with named ranges' workbook, to code that just opens a drop down in row 'E' using the named range 'Products' found on the Totals sheet?

    Thanks!!

    Andrew
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Does anyone know how to do this??

    Thanks,
    Andrew

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VB to activate list drop-down boxes when data is entered in a cell

    I have a Validation drop down box (column B) and a defined range drop down box (column E linked to the Totals tab with A2-A31 defined as Products) that I need to activate everytime data is added to a new line in column 'A' and cells in column 'B' or 'E' are selected. Additionally, they need to activate if the cells in column 'B' or 'E' are selected for any of the old data so changes can be made.
    Andrew - what exactly do you mean by 'activate'? What do you want to happen when these things happen as I'm not entirely clear?

  8. #8
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Stephen,
    When the user clicks on a blank cell in column 'E', I want a dropdown box with the named range items to appear. I already have it for column 'B' but that is using a validation dropdown so was easier to code by recording a macro. Basically, I need the cells to be blank until they are selected (activated).

    Thanks,
    Andrew
    Attached Files Attached Files
    Last edited by drewship; 05-22-2009 at 07:46 AM. Reason: uploaded latest file

  9. #9
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Sorry, still not quite clear. Isn't that what you have? The last few cells in col E are blank and when you select them the validation drop down appears.

  10. #10
    Registered User
    Join Date
    05-12-2009
    Location
    Kingston, Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Ok, if I understand what you are having trouble with, it is that you have a dynamic range of cells with a name (let's say "listname") and every time things are changed you want the dropdown list that references that range to add in the new cell values?

    If so, then this is the validation code you want. It looks like you have the code you need for the rest of it. The important change is highlighted in red.

    Please Login or Register  to view this content.
    Just change 'listname' in the code to whatever your dynamic range is named. Hope this helps.

  11. #11
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Sorry Stephen. Those are just copied down from above. I do not want these to be copied down since I would have to copy down all 65,000+ rows. I am looking for something along the lines of:

    Please Login or Register  to view this content.
    where Products in the code will open a drop down with a list of the products from the named range. The above code will not work and I have been trying variations with no success.

    Ziilch, I will try your revision. It looks similar to the above so hopefully that will do the trick.

    Thanks,
    Andrew

  12. #12
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    The code change did not work. I received a 'variable not defined' error and although I tried to define it several different ways, I could not get

    Please Login or Register  to view this content.
    to refer to the named range 'Products' on the Totals sheet and just changiing the code to

    Please Login or Register  to view this content.
    resulted in the same error. I only found 1 reference to it in the forum but it did not help me understand what I needed to do. I am looking through Google now...

    Andrew

  13. #13
    Registered User
    Join Date
    05-12-2009
    Location
    Kingston, Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Sorry about that. The code I gave would work if you had a variable "listname" in your code that contained the named range. This code should validate for a range named "Products" in your spreadsheet.

    Please Login or Register  to view this content.
    It's the double equals sign that's important.

  14. #14
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Thanks, that did it!!

    There is just a small issue now with the sequence of the code.

    Please Login or Register  to view this content.
    The dark blue should run first.
    The red should run second.
    The orange should run third.

    The new code for the Products named range does not work in this order. If I remove the comments from the purple and comment out the orange it works, but data entry jumps from column 'A' to column 'E'. How can I force these to run in sequence?

    Thanks,
    Andrew
    Last edited by drewship; 05-22-2009 at 11:16 AM.

  15. #15
    Registered User
    Join Date
    05-12-2009
    Location
    Kingston, Canada
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Ok, I think I know what you mean. When the code runs, your cursor gets moved to Column E where the dropdown was just revalidated, correct? Toss this code in at the end of your current code and it should reselect the original cell.

    Please Login or Register  to view this content.
    I'm not sure, but i think the red section reselects the target cell when it is formatting, which would explain why it works the one way only.

    If this is an event macro that runs every time you select a cell in the target range, you may also want to toss these in around the entire code:

    Please Login or Register  to view this content.
    Put the first line at the very top, and the second at the very bottom (just inside the sub declaration and end). That way, if your code ever selects another cell in that range in order to do something, you won't endless loop.

    Hope that's what you were asking.
    Last edited by Ziilch; 05-22-2009 at 11:30 AM.

  16. #16
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: VB to activate list drop-down boxes when data is entered in a cell

    Thanks Ziilch. I was able to use

    Please Login or Register  to view this content.
    so that section of the code is working!!

    Andrew

+ 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