I would really appreciate it if you could help because I really would like to get this to work. I have some code here that is meant to extract information from one part of a spreadsheet and paste it into a table on another part of the spreadsheet.
For i = 1 To 24
Range("J11:J100").Select
Set foundCell = Cells.Find(What:="PL " & i, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If Not foundCell Is Nothing Then
foundCell.Activate
foundCell.Copy
Range("P" & (i + 10)).Select
ActiveSheet.Paste
End If
Next
The main issue is that I would like to also copy information from surrounding columns using foundCell as a reference eg. foundCell.Offset(, -4).Copy
I added this but it doesn't work (addendum is marked up):
For i = 1 To 24
Range("J11:J100").Select
Set foundCell = Cells.Find(What:="PL " & i, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If Not foundCell Is Nothing Then
foundCell.Activate
foundCell.Copy
Range("P" & (i + 10)).Select
ActiveSheet.Paste
' BEGIN ADDITION
foundCell.Offset(, -4).Copy
Range("S" & (i + 10)).Select
ActiveSheet.Paste
'END ADDITION
End If
Next
I tested around and found that the foundCell is instead now referencing the range that the data was pasted to rather than the original range in which it was found.
Can anyone help me? I'm open to anything. I feel like the best solution would be to turn foundCell into a range, but I don't know how to do that.