Hi, I wonder whether someone could help me please.
I'm using the code below to find a cell value and then copy and paste into "Sheet 1".
The problem I'm having is that I'd like to amend this, so that rather than having the need to have a "Sheet1" in my source sheet, I'd like to open a new workbook and paste the data into there.
In addition I'd like to only copy columns A, C and D.
I've spent over a day on this now, and although I've tried various combinations of code I still can't get this to work.
I just wondered whether someone may be able to look at this please and offer some guidance on how I may be able to achieve this.
Many thanks and kind regards
Chris
I'm using the code below to find a cell value and then copy and paste into "Sheet 1".
Code:
Dim Src As Worksheet, Dst As Worksheet
Dim LastRow As Long, r As Range
Dim CopyRange As Range
'Change these to the correct sheet names
Set Src = Sheets("Amalgamation of Search")
Set Dst = Sheets("Sheet1")
LastRow = Src.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For Each r In Src.Range("C2:C" & LastRow)
If r.Value = "SC" Then
If CopyRange Is Nothing Then
Set CopyRange = r.EntireRow
Else
Set CopyRange = Union(CopyRange, r.EntireRow)
End If
End If
Next r
If Not CopyRange Is Nothing Then
CopyRange.Copy Dst.Range("A1")
End If
End Sub
The problem I'm having is that I'd like to amend this, so that rather than having the need to have a "Sheet1" in my source sheet, I'd like to open a new workbook and paste the data into there.
In addition I'd like to only copy columns A, C and D.
I've spent over a day on this now, and although I've tried various combinations of code I still can't get this to work.
I just wondered whether someone may be able to look at this please and offer some guidance on how I may be able to achieve this.
Many thanks and kind regards
Chris
Last edited: