Hey Guys,
I'm a VBA beginner and I've spent last 6 hours trying to make my macro copy content of one worksheet into another if cell value equals certain string. It works well when the data is pasted in the exact same columns (A:Q) but it doesn't when I try to paste the data into a different range (C:S).
Excel tells me that it cannot be pasted because copy and paste area are of different shape and size which is untrue. The same operation is completed without a problem when done manually or using simple destination copy without a condition.
Below is my code:
Thanks in advance for all your help.
I'm a VBA beginner and I've spent last 6 hours trying to make my macro copy content of one worksheet into another if cell value equals certain string. It works well when the data is pasted in the exact same columns (A:Q) but it doesn't when I try to paste the data into a different range (C:S).
Excel tells me that it cannot be pasted because copy and paste area are of different shape and size which is untrue. The same operation is completed without a problem when done manually or using simple destination copy without a condition.
Below is my code:
Code:
Sub copydata()
Dim value As Range
Dim start As Integer
Dim srcSh As Worksheet
Dim trgSh As Worksheet
Set srcSh = ActiveWorkbook.Worksheets("Data")
Set trgSh = ActiveWorkbook.Worksheets("Ready")
start = 12
For Each value In srcSh.Range("A2:Q500")
If value = "Reviewed" Then
srcSh.Rows(value.Row).copy trgSh.Rows(start).Range("C12")
start = start + 1
End If
Next value
End Sub
Thanks in advance for all your help.
Last edited: