Results 1 to 3 of 3

Create Drop-down List with Excel VBA

Threaded View

AAS44 Create Drop-down List with... 08-13-2019, 11:20 AM
nigelog Re: Create Drop-down List... 08-13-2019, 12:44 PM
AliGW Re: Create Drop-down List... 08-13-2019, 12:49 PM
  1. #1
    Registered User
    Join Date
    07-23-2019
    Location
    TW
    MS-Off Ver
    2016
    Posts
    12

    Create Drop-down List with Excel VBA

    I want to create a drop-down list in Cell E5.

    My range of values for the drop-down should come from Range(A1:A5) in Sheet2 and Range(C1:C7) in Sheet2. However, my code below is not working, it runs an error 1004 at Add xlValidateList, xlValidAlertStop, Operator:=xlBetween, Formula1:="=Sheet2!$A$1:$A$5 & Sheet2!$C$1:$C$7" I suspect it has something to do with this line...Formula1:="=Sheet2!$A$1:$A$5 & Sheet2!$C$1:$C$7" . Does anyone know how I can add two ranges into my Formula1?

    Also, I dont want the blanks in the ranges to appear in the Drop-down list but .IgnoreBlank = True still shows the blanks in the drop-down list. This is my code thus far, any help is genuinely appreciated:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    If Not Intersect(Target, Range("E5")) Is Nothing Then
    
    With Range("e5").Validation
    .Add xlValidateList, xlValidAlertStop, Operator:=xlBetween, Formula1:="=Sheet2!$A$1:$A$5 & Sheet2!$C$1:$C$7"
    .IgnoreBlank = True
    .InCellDropdown = True
    .ErrorTitle = "Warning"
    .ErrorMessage = "Please select a value from the drop-down list available."
    .ShowError = True
    
    End With
    
    End If
    
    End Sub
    Last edited by AliGW; 08-13-2019 at 12:48 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Create an Excel Drop Down list with Search Suggestions ( Serachable Dropdown list )
    By PMH2384 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-11-2016, 12:03 AM
  2. how to create drop down list in excel with colors
    By kisanvikas2015 in forum Excel General
    Replies: 3
    Last Post: 05-21-2015, 08:53 AM
  3. Create a drop down list from other excel sheet
    By kisanvikas2015 in forum Excel General
    Replies: 2
    Last Post: 04-25-2015, 04:58 AM
  4. How to create drop down list in Excel where each list item is based on two columns?
    By matkiros in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2012, 08:50 AM
  5. Excel VBA Macro to create a drop down list
    By jeffgraser in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2009, 08:08 PM
  6. How do I create a drop down list in Excel 2003
    By Lenny in forum Excel General
    Replies: 1
    Last Post: 02-18-2005, 10:06 AM
  7. Is there a way to create a drop-down list of links in Excel?
    By t_boden in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-03-2005, 03:06 PM

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