+ Reply to Thread
Results 1 to 3 of 3

Adding drop down list macro

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Adding drop down list macro

    Good evening everyone,

    I am having trouble adding more drop down list too my macro. I already have column (B) done, still need to do columns (C,D,E,F,G). I Also have my macro adding a new row at (A2) when I click my Active X button found in cells (K1,L1). So when I click my Active X button a New Row is added as well as a drop down list in cell (B2),I know you can't see my Active X button well but I can't get the text too show because it is a small button and want it that way,have tried everything in the properties area.

    Can someone help me add these other drop down list commands to my macro for columns (C2,D2,E2,F2,G2)?

    The code I am working with
    Private Sub CommandButton1_Click() 
         
        Sheets("Search").Range("A2").Select 
        ActiveCell.EntireRow.Insert Shift:=xlDown 
         
        Sheets("Search").Range("A2:G2").Select 
        Selection.Borders.Weight = xlThin 
         
        Sheets("Search").Range("B2").Select 
        With Selection.Validation 
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _ 
            Formula1:="=data_2!$A$2:$A$19" 
            .IgnoreBlank = True 
            .InCellDropdown = True 
        End With 
    End Sub
    Here is my workbook

    Thank you for your time,
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Adding drop down list macro

    This will do


    Private Sub CommandButton1_Click()
    Sheets("Search").Range("A2").EntireRow.Insert Shift:=xlDown
    With Sheets("Search").Range("A2:G2").Borders
        .Weight = xlThin
    End With
    With Sheets("Search").Range("B2").Validation
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _
        Formula1:="=data_2!$A$2:$A$19"
    End With
    With Sheets("Search").Range("C2").Validation
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _
        Formula1:="=data_2!$B$2:$B$154"
    End With
    With Sheets("Search").Range("D2").Validation
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _
        Formula1:="=data_2!$C$2:$C$51"
    End With
    With Sheets("Search").Range("E2").Validation
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _
        Formula1:="=data_2!$D$2:$D$17"
    End With
    End Sub
    Kind regards
    Leo

  3. #3
    Forum Contributor
    Join Date
    06-23-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    239

    Re: Adding drop down list macro

    You are the MAN ,Thank you Leo!!
    Have a GREAT DAY!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Adding Pictures From Drop Down List
    By TDeRanger in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2013, 12:49 PM
  2. Adding drop down List to Cell
    By nalgene5622 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-24-2012, 10:58 AM
  3. Problem adding to drop down list
    By jonhunt in forum Excel General
    Replies: 2
    Last Post: 11-27-2007, 12:00 PM
  4. Adding a Drop Down List to a Column?
    By Stacy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. Adding a Drop Down List to a Column?
    By Stacy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 AM
  6. [SOLVED] Adding a Drop Down List to a Column?
    By Stacy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. [SOLVED] Adding a Drop Down List to a Column?
    By Stacy in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. Adding value to drop down list
    By neb in forum Excel General
    Replies: 3
    Last Post: 06-24-2005, 08:40 AM

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