Reputation: 35
I have this piece of code: I would like to do a left function on cells G and M in the following code: I am having an issue as when I try:
If left(.Cells(i, "G",4)) <> left(.Cells(i, "M",4)) this does not work.
any advice?
Here is the full code:
Sub SingleTradeMove()
Dim wsTD As Worksheet
Set wsTD = Worksheets("Trade data")
Sheets("Sheet2").Range("A2:AK600").ClearContents
With wsTD
lastRow = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 2 To lastRow
If .Cells(i, "G") <> .Cells(i, "M") _
Or .Cells(i, "I") <> .Cells(i, "O") _
Or .Cells(i, "L") <> .Cells(i, "R") Then
.Cells(i, "J").EntireRow.Copy _
Destination:=Sheets("Sheet2").Range("A" &
Rows.Count).End(xlUp).Offset(1)
End If
Next i
End With
End Sub
Upvotes: 0
Views: 257
Reputation: 23974
You need to use
If left(.Cells(i, "G"),4) <> left(.Cells(i, "M"),4)
Upvotes: 2