Hello all,
I am trying to copy/paste specific cells from rows that contain the word "YES" into another worksheet.
Let me say that I am brand new to VBA and just starting to understand, but am far from mastering this art.
So far, this is what I have; it copies the cells from column D to AA, but I only really need the values from columns D and P:AA (E:O are not needed).
Is it also possible to paste these values beginning in the target sheet's column B? I need the current values from column A to stay there and not be replaced.
Thank you very much in advance for your replies! I've been trying to figure this out for a while.
Code:
I am trying to copy/paste specific cells from rows that contain the word "YES" into another worksheet.
Let me say that I am brand new to VBA and just starting to understand, but am far from mastering this art.
So far, this is what I have; it copies the cells from column D to AA, but I only really need the values from columns D and P:AA (E:O are not needed).
Is it also possible to paste these values beginning in the target sheet's column B? I need the current values from column A to stay there and not be replaced.
Thank you very much in advance for your replies! I've been trying to figure this out for a while.
Code:
Code:
Sub CopyYes()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
Set Source = ActiveWorkbook.Worksheets("2020 Budget")
Set Target = ActiveWorkbook.Worksheets("Shutdown 2020")
j = 4 ' Paste starting in 4th row of target worksheet
For Each c In Source.Range("O7:O500")
If c = "YES" Then
Source.Range("D" & c.Row & ":AA" & c.Row).Copy Target.Rows(j) 'Copy from cells D to AA
j = j + 1
End If
Next c
End Sub