Private Sub CommandButton1_Click() '给商品代码下拉列表赋值 Dim tb As ListObject Set tb = Sheet1.ListObjects("表_入库") Dim S01 As Object Set S01 = Sheets("Config") Dim common As New common Dim rMax As Long rMax = common.getLastRow(S01, "A") 'S01.Range("A65535").End(xlUp).Row With Sheet1.Range("D8:D" & 7 + tb.ListRows.Count).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=" & S01.Name & "!$A$2:$A$" & rMax End With End Sub
标签:Dim,vba,End,验证,S01,rMax,tb,common,数据 From: https://www.cnblogs.com/Insist-Y/p/16950344.html