以下代码正在删除记录,但我想将下一列更新为" OK"而不是删除整行。请告知所需的所有更改。
Dim myFileNameDir As String
Dim ws1 As Worksheet
Dim iRow1 As Long
Dim str As String
myFileNameDir = "C:\Users\GShaikh\Desktop\Book16.xlsx"
Workbooks.Open Filename:=myFileNameDir, UpdateLinks:=0
Set ws1 = Worksheets("Students")
str = ListView1.SelectedItem.SubItems(1)
MsgBox str
With ws1
.AutoFilterMode = False
iRow1 = .Range("B" & .Rows.Count).End(xlUp).row
With .Range("B1:D" & iRow1)
.AutoFilter Field:=1, Criteria1:="=*" & str & "*"
.Offset(1, 0).SpecialCells (xlCellTypeVisible).EntireRow.Delete
End With
.AutoFilterMode = False
End With
ActiveWorkbook.Save
ActiveWorkbook.Close
答案 0 :(得分:1)
您需要删除:(xlCellTypeVisible).EntireRow.Delete
并将其替换为类似Cells.Value =“OK”