将自动完成添加到下拉列表宏

时间:2014-03-19 19:52:45

标签: excel-vba vba excel

有没有办法为此宏添加自动完成功能,以便当usue开始在A列中输入单元格时自动完成

谢谢

Sub CreateDV()
Dim rng As Range
Dim cell As Range
Dim lRow As Long
Dim ws As Worksheet

Sheets("New").Select
Set ws = Sheets("New")

   lRow = ws.Range("A" & ws.Rows.count).End(xlUp).Row

  Set rng = Range("A4:A" & lRow)

With rng.Validation
   For Each cell In rng
     .Delete
     .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
     xlBetween, Formula1:="Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday"
     .IgnoreBlank = True
     .InCellDropdown = True
     .InputTitle = ""
     .ErrorTitle = ""
     .InputMessage = ""
     .ErrorMessage = ""
     .ShowInput = True
     .ShowError = True
   Next cell
 End With
End Sub

0 个答案:

没有答案