VBA IndexMatch then Paste Values

phillip87

Board Regular
Joined
Jan 28, 2019
Messages
76
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.

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

1740960186042.png
 
Last edited by a moderator:
Try:
VBA Code:
foundCell.offset(1,0) PasteSpecial xlPasteValues
foundCell.offset(1,0) PasteSpecial xlPasteFormats
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top