I have the macro below that works with ordinary text strings, but will not work with the lists of URLs I have. Is this because of special characters?
The code:
As mentioned, the macro works OK with ordinary text strings, so I am puzzled!
Help very gratefully received!
The code:
- Looks up a URL in column B in Sheet2
- Finds the matching URL in column B in Sheet1
- Copies cells in cols C to D in row in Sheet1 with the matching URL
- Pastes the copied cells into adjacent cells in Sheet2
As mentioned, the macro works OK with ordinary text strings, so I am puzzled!
Help very gratefully received!
Code:
Sub Get_PDF_pageviews()
Dim cell As Range
Dim PDF_URL As Variant
Dim LastRow As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
Worksheets("Sheet2").Activate
With Worksheets("Sheet2")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
For Each PDF_URL In Sheets("Sheet2").Range("B2:B" & LastRow).Cells
Set cell = Sheets("Sheet1").Range("B:B").Find(PDF_URL, , xlValues, xlWhole, xlByRows, False, False, False)
If Not cell Is Nothing Then
cell.Offset(, 1).Resize(, 2).Copy Destination:=Worksheets("Sheet2") _
.Range("B:B").Find(PDF_URL, , xlValues, xlWhole, xlByRows, False, False, False).Offset(, 1)
End If
Next PDF_URL
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub