作者:fghnh102_441 | 来源:互联网 | 2023-05-18 23:19
Iwouldliketogetridofthesht2.Selectandsht2.Range(B2).Selectinthecodebelow.Istherea
I would like to get rid of the sht2.Select
and sht2.Range("B2").Select
in the code below. Is there a way to do this?
我想摆脱sht2.Select和sht2.Range(“B2”)。在下面的代码中选择。有没有办法做到这一点?
Sub Remaining()
Dim sht2 As Worksheet
Dim cell As Range
Set sht2 = ThisWorkbook.Worksheets("Sheet2")
sht2.Select
sht2.Range("B2").Select
With sht2
For Each cell In .Range("B2", Cells(Rows.Count, "B").End(xlUp))
If .Range("A:A").Find(What:=cell.Value2, LookAt:=xlWhole) Is Nothing Then
Intersect(.UsedRange, cell.EntireRow).Offset(, 1).Copy Sheets("Sheet1").Cells(Rows.Count, "L").End(xlUp).Offset(1)
cell.Interior.Color = vbYellow
End If
Next cell
End With
End Sub
1 个解决方案