The below correctly checks the date and pastes in the values into the correct sheet/column.
However.......
1. I am needing this to paste under the date not over the top of it
2. I need this to only copy the values where both the date and category match
Sheet 2 is a dynamic table so the categories may or may not be listed depending on if they have a value which is why I need to INDEXMATCH rather than just copy a range.
However.......
1. I am needing this to paste under the date not over the top of it
2. I need this to only copy the values where both the date and category match
Sheet 2 is a dynamic table so the categories may or may not be listed depending on if they have a value which is why I need to INDEXMATCH rather than just copy a range.
VBA Code:
Sub findAndCopy()
Dim foundCell As Range, sh2, sh As Worksheet
'Set sheets
Set sh2 = Sheets("Refresh Data Report")
Set sh3 = Sheets("Ongoing Record")
'Find string in column C of Sheet2
Set foundCell = sh3.Range("B:H").Find(sh2.Range("AP1").Value, , xlValues, xlWhole)
If Not foundCell Is Nothing Then 'If match cell is found
sh2.Range("AI3:AI30").Copy
foundCell.PasteSpecial xlPasteValues
foundCell.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
Else
Call MsgBox("Not found the match cell!", vbExclamation, "Finding String")
End If
End Sub
Last edited by a moderator: