J
Joe Clueless
Need some help please, somebody has provided me with the the following macro
and I need to make a change but i'm not exactly sure how to implement the
change.
At present I am unable to get in touch with the person , that provided it
and I need to try and get this all done this afternoon.
The instruction was as follows : "you might have some unwanted spaces in at
the begining or end of the data.Try altering the second line as shown below"
How do i put this
For Each Dn1 In Rng1
If Trim(Dn2) = Trim(Dn1) Then 'Alter this line
into this, do i append it to line 2 or what.
thanks if you can help
Sub compare
Dim Rng1 As Range, Dn1 As Range, Rng2 As Range, Dn2 As Range
With Sheets("Sheet1") '1
Set Rng1 = .Range(.Range("E1"), .Range("E" & Rows.Count).End(xlUp))
End With
With Sheets("Sheet2") '2
Set Rng2 = .Range(.Range("E1"), .Range("E" & Rows.Count).End(xlUp))
End With
For Each Dn2 In Rng2
For Each Dn1 In Rng1
If Dn2 = Dn1 Then
Dn1.Offset(, -4).Resize(, 31).Copy Dn2.Offset(, -4).Resize(,
31)
End If
Next Dn1
Next Dn2
End Sub
and I need to make a change but i'm not exactly sure how to implement the
change.
At present I am unable to get in touch with the person , that provided it
and I need to try and get this all done this afternoon.
The instruction was as follows : "you might have some unwanted spaces in at
the begining or end of the data.Try altering the second line as shown below"
How do i put this
For Each Dn1 In Rng1
If Trim(Dn2) = Trim(Dn1) Then 'Alter this line
into this, do i append it to line 2 or what.
thanks if you can help
Sub compare
Dim Rng1 As Range, Dn1 As Range, Rng2 As Range, Dn2 As Range
With Sheets("Sheet1") '1
Set Rng1 = .Range(.Range("E1"), .Range("E" & Rows.Count).End(xlUp))
End With
With Sheets("Sheet2") '2
Set Rng2 = .Range(.Range("E1"), .Range("E" & Rows.Count).End(xlUp))
End With
For Each Dn2 In Rng2
For Each Dn1 In Rng1
If Dn2 = Dn1 Then
Dn1.Offset(, -4).Resize(, 31).Copy Dn2.Offset(, -4).Resize(,
31)
End If
Next Dn1
Next Dn2
End Sub