-
That error will occur if there is no date in Sheet 2 to match that in found on Sheet 1
This has error handling added
[VBA]Sub Test()
Dim r As Range, cel As Range, tgt As Range
Set r = Sheets(1).Range("B1:AC500").SpecialCells(xlCellTypeConstants)
On Error Resume Next
For Each cel In r
If IsDate(cel) Then
Set tgt = Sheets(2).Rows(1).Find(cel)
Sheets(2).Cells(Rows.Count, tgt.Column).End(xlUp)(2) = Sheets(1).Cells(cel.Row, 1)
If Err <> 0 Then
MsgBox "Date " & cel & " not found"
Err.Clear
End If
End If
Next
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules