+ Reply to Thread
Results 1 to 9 of 9

Macro to create drop down menuin a cell

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Macro to create drop down menuin a cell

    Hi,

    I am trying to create a drop down menu in a specific cell on a sheet using a macro. The named list is on a hidden sheet. I am using the following code but it is giving me an error: "Application-defined or object-defined error. " #1004

    Sub Add_Drop_Down_Menu_Cell(ByVal menuList As Range)
    With ThisWorkbook.Sheets("Filtered Data").Range("B5").Validation
    .Delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=menuList"
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
    End With
    End Sub

    The error is being generated by the .Add part of the code. Can anyone please help me resolve this? Thank you.

  2. #2
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Macro to create drop down menuin a cell

    Hello,

    Your code works so good to me
    Please Login or Register  to view this content.
    Harry.

  3. #3
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Macro to create drop down menuin a cell

    I am not sure what you mean by your post Harry. In the code you posted menuList is not defined. I pass it as a parameter to the sub. I also get an error on the .Add part.

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Macro to create drop down menuin a cell

    I have manually created in Menu → Insert → Names the menuList.

  5. #5
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Macro to create drop down menuin a cell

    Hmmm. Then I a not sure why I am getting an error. I am running this from a macro.

  6. #6
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Macro to create drop down menuin a cell

    Try this example.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Macro to create drop down menuin a cell

    Does it matter that the menuList comes from a sheet that is hidden?

  8. #8
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Macro to create drop down menuin a cell

    If you've tried the file?

  9. #9
    Registered User
    Join Date
    04-30-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Macro to create drop down menuin a cell

    Thanks Harry. The sheet does not really run the macro; i.e. nothing happens. One issue I noticed is that menuList in you code is a named range. I need menuList to be a variable because I need to use a number of lists. That is why I pass it as a parameter.

+ 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