Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,066
- Office Version
- 2016
- Platform
- Windows
The code below works fine if seperated but together I get the folllowing error message
"Compiler error Invalid qualifier"
The code takes a list of url from sheet2 "URL LIST" and extracts the data from IE, pasting it into sheet1, it then deletes any blank rows. I did have a delete duplicate, but for some reason it was deleting data that were not duplicates (shown in orange below.)
The second bit of code I added is shown in blue at the bottom of the code, on its own it works fine, as does the top code. This blue code checks rows in column A and if they don't have a SPECIAL Character, in this case "www" it deletes them (Shown in green).
I get the "Compiler error Invalid qualifier" message in the bit show in red below, can someone help
Thanks
"Compiler error Invalid qualifier"
The code takes a list of url from sheet2 "URL LIST" and extracts the data from IE, pasting it into sheet1, it then deletes any blank rows. I did have a delete duplicate, but for some reason it was deleting data that were not duplicates (shown in orange below.)
The second bit of code I added is shown in blue at the bottom of the code, on its own it works fine, as does the top code. This blue code checks rows in column A and if they don't have a SPECIAL Character, in this case "www" it deletes them (Shown in green).
I get the "Compiler error Invalid qualifier" message in the bit show in red below, can someone help
Code:
Private Sub CommandButton4_Click()
Dim i, j, k, l As Integer
i = 2
k = 2
l = 2
'SHEET2 as sheet with URL
Dim wsSheet As Worksheet, Rows As Long, links As Variant, ie As Object, link As Variant
Set wb = ThisWorkbook
Set wsSheet = wb.Sheets("URL LIST")
'Set IE = InternetExplorer
Set ie = CreateObject("InternetExplorer.Application")
Rows = wsSheet.Cells(wsSheet.Rows.Count, "A").End(xlUp).Row
links = wsSheet.Range("A1:A" & Rows)
'IE Open Time per page 5sec and check links on Sheet2 Column A
With ie
.Visible = True
Application.Wait (Now + TimeValue("00:00:5"))
For Each link In links
.navigate (link)
While .Busy Or .READYSTATE <> 4: DoEvents: Wend
x = .document.body.innerText
x = Replace(x, Chr(10), Chr(13))
x = Split(x, Chr(13))
Range("A1").Resize(UBound(x)) = Application.Transpose(x)
For i = 1 To 5000
On Error Resume Next
'Paste in sheet and column
Dim rw As Long
rw = Sheet1.Cells(Sheet1.Rows.Count, 1).End(xlUp).Row + 1
Sheets("Sheet1").Range("A" & rw).Value = ie.document.getElementsByTagName("a").Item(i).innerText
Next i
'Deletes duplicates in column A Sheet1
[COLOR=#ff8c00]'Columns(1).RemoveDuplicates Columns:=Array(1)[/COLOR]
'navigate links
Next link
'Close IE Browser
ie.Quit
Set ie = Nothing
' Deletes any blank rows as data pased into excel as too many blank rows
Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
' Deletes any rows in column A if it does not have a SPECIAL Character as shown in RED
[COLOR=#0000cd]Dim r As Long, lr As Long
lr = Cells([/COLOR][COLOR=#ff0000]Rows[/COLOR][COLOR=#0000cd].Count, 1).End(xlUp).Row
For r = lr To 2 Step -1
If InStr(Cells(r, 1), "[/COLOR][COLOR=#008000]www[/COLOR][COLOR=#0000cd]") = 0 Then Rows(r).Delete
Next r
End With[/COLOR]
End Sub
Thanks