Consulting

Results 1 to 5 of 5

Thread: Add DropDownLines

  1. #1

    Add DropDownLines

    In The Sheet I need more Lines in the DropDownContrl.
    How this make?
    MacroRecorder dont help me!

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings,

    In your example wb, you have Data Validation using a range of cells as a list, and you also have Forms type drop-down that uses the same range as the Input Range.

    As you mention trying the macro recorder, I am guessing that you want to make some type of list dynamic. Do you care whether its thru DV, drop-down, or activex?

    Also, what is the criteria that we need to meet to size/repopulate?

    Mark

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    [vba]Option Explicit
    Private Sub CommandButton1_Click()

    With ActiveSheet.Shapes("my control")
    .ListFillRange = "Sheet1!$A$1:$A$499"
    .LinkedCell = ""
    .DropDownLines = 155
    .Display3DShading = False
    End With
    End Sub[/vba]

    see attached.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    Thanks Lucas, GTO.
    That Forms type drop-down was example.

    GTO.
    Yes.This is Data, Validation, List...
    Criteria= Visible part of WorkSheet i.e. ca 155 Listitems.

    [vba]
    Private Sub CommandButton2_Click()
    Dim LastRow As Long
    Sheets("Sheet2").Activate
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    Range("A2").Select
    With Selection.Validation
    ' .Delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
    xlBetween, Formula1:="=INDIRECT(""Sheet1!$A:$A"")"
    ' .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
    xlBetween, Formula1:="=INDIRECT(""Sheet1!.Range("A1:A" & LastRow)"")"

    .DropDownLines = ActiveSheet.Range("A2").Value ' Or .DropDownLines = 155
    .IgnoreBlank = True
    .InCellDropdown = True
    .InputTitle = ""
    .ErrorTitle = ""
    .InputMessage = ""
    .ErrorMessage = ""
    .ShowInput = True
    .ShowError = True
    End With
    End Sub[/vba]

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I don't believe there is any way to increase the number of lines in DV.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •