Hi guys and girls,
Anyone know how to solve this little puzzle?
I'm trying to copy each cell from a range depending on whether a condition is met in an adjacent column i.e. value in the range = 1, to a location on another worksheet. However when I run the macro I keep getting the error "Run-time error 1004: copy method of the range class failed". The help on the MSDN website doesn't seem to apply to me.
Any help would be great!
Thanks
J
PHP Code:
Sub CreateBuySD()
Dim SD1 As Worksheet
Dim SD2 As Worksheet
Set SD1 = Worksheets(1)
Set SD2 = Worksheets(2)
Dim BuyRange As Range
Set BuyRange = SD1.Range("P4,P1004")
Dim DestRange As Range
Set DestRange = SD2.Range("A1")
Dim signal As Variant
For Each signal In BuyRange
Dim Change As Range
Set Change = signal.Offset(-1, 1)
If signal = 1 Then
Change.Copy Destination:=DestRange.End(xlDown).Row
End If
Next signal
End Sub
Bookmarks