kevin lazell
Well-known Member
- Joined
- Jun 2, 2004
- Messages
- 513
hi guys i have written this piece of code for my daughter which work ok on my machine excel2019
but will not run on hers runtime error 1004 is what she gets could this be a compatibility issue and is there a work around
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim X, Y, Z As Variant
Dim i As String
Range("d17") = "word"
i = "19th jul 2021"
Z = Range("D" & Rows.Count).End(xlUp).Row
Z = Z + 1
X = 2: Y = 2
again:
Do
If Range("D" & X) <> Sheets(i).Range("D" & Y) Then Y = Y + 1: GoTo again: 'this line gives the error
If Range("D" & X) = Sheets(i).Range("D" & Y) Then Range("O" & X).Copy
With Sheets(i).Range("O" & Y).PasteSpecial: X = X + 1: Y = 2
Application.CutCopyMode = False
End With
If X = Z Then Exit Sub
Loop
End Sub
thank you for any help she is running 365 by the way
but will not run on hers runtime error 1004 is what she gets could this be a compatibility issue and is there a work around
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim X, Y, Z As Variant
Dim i As String
Range("d17") = "word"
i = "19th jul 2021"
Z = Range("D" & Rows.Count).End(xlUp).Row
Z = Z + 1
X = 2: Y = 2
again:
Do
If Range("D" & X) <> Sheets(i).Range("D" & Y) Then Y = Y + 1: GoTo again: 'this line gives the error
If Range("D" & X) = Sheets(i).Range("D" & Y) Then Range("O" & X).Copy
With Sheets(i).Range("O" & Y).PasteSpecial: X = X + 1: Y = 2
Application.CutCopyMode = False
End With
If X = Z Then Exit Sub
Loop
End Sub
thank you for any help she is running 365 by the way