我试图删除项目在用户表单和电子表格,但当我点击删除按钮,最后一个项目(纸张传输文件(黄色))被删除在用户表单,但它仍然在电子表格。不知道出了什么问题。
用户表单中的项目
的数据
在用户表单中删除的项目
的
工作表中保留的最后一个项目
的
请看下面的代码。
Dim s As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Data")
Dim selectedItems As New Collection
For s = s To Me.ListboxResult.ListCount - 1
If Me.ListboxResult.Selected(s) Then
selectedItems.Add s
End If
Next s
For s = selectedItems.Count To 1 Step -1
Me.ListboxResult.RemoveItem selectedItems(s)
ws.Rows(selectedItems(s) + 4).Delete
MsgBox "The selected item(s) Is/are successfully removed.", vbOKOnly, "Removal Successful"
Next s
'Uncheck the checkbox if the listbox is empty
If Me.ListboxResult.ListCount = 0 Then
Me.checkboxSelect.Value = False
MsgBox "The selected item(s) Is/are successfully removed.", vbOKOnly, "Removal Successful"
End If
字符串
下面有这个代码
For Each Cell In rng
With Cell
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
Next Cell
型
我希望在用户表单和电子表格中删除该项目
2条答案
按热度按时间laximzn51#
当您发现行被选中时,将其删除。
字符串
u1ehiz5o2#
Me.ListBox1.Selected(s)
的索引是零基。paper transfer file(yellow)
的索引是2
。paper transfer file(yellow)
位于工作表上的单元格E7
中字符串
更新:
问题:因为每次我添加到电子表格中的项目都不相同
型