我有一个列,其中有多个值从A2开始。我要做的是删除从用户表单组合框中收集的值,然后删除空白单元格(向上移动)。 这就是我迄今为止所做的:
Dim RowCount As Long
Dim Found As Range
RowCount = Worksheets("Config").Range("A1").CurrentRegion.Rows.Count
Set Found = Worksheets("Config").Columns("B").Find(what:=Me.ProjectManagersCombo.Value, LookIn:=xlValues, lookat:=xlWhole)
Found.Delete (xlShiftUp)
然而,这不起作用,我得到运行时错误91.有什么问题,我该如何解决?
答案 0 :(得分:0)
Sub DropDown1_Change()
For a = 2 To 1000000
If Sheet1.Range("A" & a) = _
Sheet1.Shapes("1").ControlFormat.List(Sheet1.Shapes("1").ControlFormat.ListIndex) _
Then
Sheet1.Rows(a).Delete
Exit For
End If
Next a
End Sub
上面的子组件被分配给组合框,形状(“1”)是组合框形状,将“1”更改为形状名称。
越短越好:
For a = 2 To 1048576
If Sheet1.Range("A" & a) = Sheet1.Shapes("1").ControlFormat.List(Sheet1.Shapes("1").ControlFormat.ListIndex) Then Sheet1.Rows(a).Delete: Exit For
Next a