PDA

View Full Version : Add DropDownLines



omnibuster
12-19-2009, 03:55 PM
In The Sheet I need more Lines in the DropDownContrl.
How this make?
MacroRecorder dont help me!

GTO
12-19-2009, 04:55 PM
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

lucas
12-19-2009, 05:38 PM
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

see attached.

omnibuster
12-20-2009, 05:16 AM
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.


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

xld
12-20-2009, 08:23 AM
I don't believe there is any way to increase the number of lines in DV.