リストを検索し、最初にスペクトル セブンを持つ列のすべてのエントリを見つけるマクロを作成しています。これは、これらのレコードを各エントリのシートにコピーすることです。
これまでのコードでは、次のように失敗します。
実行時エラー '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
矢印はエラーを指しています。