Whenever I try to use "Range" as a method in this block of code, I get an error saying range method of object class failed. Those exact same methods work just fine when they're placed into any other macro.
Any suggestions?
(The two red lines are causing the failure... the ones that specify a "Range")
Any suggestions?
(The two red lines are causing the failure... the ones that specify a "Range")
Rich (BB code):
sub test()
'==================================================
'Opens the browser and copies stuff
'==================================================
Dim Browser As Object
Set Browser = CreateObject("InternetExplorer.Application")
link = "http://www.google.com"
Browser.Navigate (link)
Browser.Visible = True
While Browser.Busy And Browser.ReadyState <> 4: DoEvents: Wend
Browser.ExecWB 17, 0
Browser.ExecWB 12, 0
Browser.Quit
'==================================================
'Pastes all website contents into worksheet
'Finds text, selects range to copy
'==================================================
ThisWorkbook.Sheets("Sheet1").Paste Destination:=Sheets("Sheet1").Range("A1")
For Each Cell In ActiveSheet.UsedRange
If Cell.Value = "text" Then
a = Cell.Offset(1, 0).Address
End If
Next
ThisWorkbook.Sheets("Sheet1").Range(a, Range(a).SpecialCells(xlCellTypeLastCell)).Copy
ThisWorkbook.Sheets("Sheet1").Range("H1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
end sub