我正在尝试找到一个脚本,它在sheet1中找到某些值并将这些值粘贴到sheet2 A1中。
目前有这个脚本:
Sub delete_oldads()
Dim cel As Range, cfind As Range
ActiveSheet.UsedRange.Select
For Each cel In Selection
If cel = "" Then GoTo nextcel
Set cfind = cel.Find(what:="1Z", lookat:=xlPart)
If Not cfind Is Nothing Then
cfind.Copy Cells(cfind.Row, "A")
cfind.Clear
End If
nextcel:
Next cel
End Sub
但是这一个在同一张纸上复制/粘贴所有匹配的单元格,如果在同一行中找到匹配,它将只复制最后一个。
答案 0 :(得分:0)
这不使用 FIND(),可能有点慢:
Sub poiuyt()
Dim K As Long, r As Range
Dim sh2 As Worksheet
Set sh2 = Sheets("Sheet2")
K = 1
With Sheets("Sheet1")
For Each r In .UsedRange
v = r.Value
If v <> "" Then
If Left(v, 1) = "W" Or Left(v, 2) = "IZ" Then
r.Copy sh2.Cells(K, 1)
K = K + 1
End If
End If
Next r
End With
End Sub