我正在制作一个宏,它将搜索一个列表并在第一个具有spectralseven 的列中找到所有条目。这会将这些记录复制到每个条目的工作表中。
到目前为止的代码失败了:
运行时错误“1004”:应用程序定义的或对象定义的错误。
Sub testWild()
startCell = 0
Dim FoundCell As Range
Dim LastCell As Range
Dim FirstAddr As String
cellRange = "A1:A20"
topCount = startCell
With Range("A1:A20")
Set LastCell = .Cells(.Cells.Count)
End With
Dim findString As String
findString = "spectraseven*"
Set FoundCell = Range(cellRange).Find(what:=findString, after:=LastCell)
If Not FoundCell Is Nothing Then
FirstAddr = FoundCell.Address
End If
Do Until FoundCell Is Nothing
Debug.Print FoundCell.Address
Set FoundCell = Range(cellRange).FindNext(after:=FoundCell)
Count = FoundCell.Row
Set FoundCell = Range(cellRange).FindNext(after:=FoundCell)
---> Sheets(1).Range("a" & topCount) = Sheets(1).Range("e" & Count)
topCount = topCount + 1
If FoundCell.Address = FirstAddr Then
Exit Do
End If
Loop
End Sub
箭头指向错误。