![]() |
Why is this code not working ?
When I press the CommandButton1 (an 'Active x' control button on the worksheet page) it says 'Sub missing' and a yellow arrow points to the
first line. - ---------------------------------------------------------------------------- Private Sub CommandButton1_Click() Sub GetHorses() Dim IE As Object Dim doc As Object Dim divRunners As Object Dim divHorse As Object Dim divCard As Object Dim tblRaceHeader As Object Dim elmt As Object Dim lnk As Object Dim strURL As String Dim ws As Worksheet Dim rng As Range strURL = "http://www.racingpost.com/horses2/ca...ate=2011-06-20" Set IE = CreateObject("InternetExplorer.Application") With IE .navigate strURL Do While .Busy: DoEvents: Loop Do While .ReadyState < 4: DoEvents: Loop .Visible = True Set ws = Worksheets.Add Set rng = ws.Range("A1") Set doc = IE.Document ' this small table has the stat headers Set tblRaceHeader = doc.getelementbyid("lc_cardHead") GetTableData tblRaceHeader, rng ws.Range("B1").Insert xlShiftToRight ws.Range("B1") = "FORM" Set rng = rng.Offset(1) Set divRunners = doc.getelementbyid("lc_sortBlock") Set divRunners = divRunners.getelementsbytagname("DIV") For Each divHorse In divRunners If divHorse.classname = "cardItem" Then For Each elmt In divHorse.all Select Case elmt.tagname Case "TABLE" Select Case elmt.classname Case "cardGl" ' this table has the runners and stats GetTableData elmt, rng End Select Case "P" End Select Next elmt End If Next divHorse IE.Quit Set IE = Nothing End With ws.Cells.WrapText = False ws.Range("A1:J1").EntireColumn.AutoFit Application.Goto Worksheets(1).Range("A1"), Scroll:=True End Sub ---------------------------------------------------------------------------- Can anyone tell me what is amiss ? I copied this code from the internet, but it is meant to work - everybody was saying what a genius the author was. Thank you for your help. Yours Simon |
Why is this code not working ?
Hi Simon,
Am Sun, 14 Dec 2014 06:19:16 -0800 (PST) schrieb : Private Sub CommandButton1_Click() Sub GetHorses() End Sub you only have a sub called GetHorses(). Delete the line Sub GetHorses() and make sure that the code is in the code module of the sheet in which the button is. Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
Why is this code not working ?
Hi Claus,
I deleted the line 'Sub Get Horses()' but the program is still not running. There is a yellow arrow still pointing to the first line - Private Sub CommandButton1_Click() Maybe it would be an idea if you copied and pasted this into your own Excel, and could troubleshoot from there ? Yours Simon |
Why is this code not working ?
Hi Claus,
I deleted the line 'Sub Get Horses()' but the program is still not running. There is a yellow arrow still pointing to the first line - Private Sub CommandButton1_Click() Maybe it would be an idea if you copied and pasted this into your own Excel, and could troubleshoot from there ? Yours Simon Did you press F5 after you delete the line? If not then your macro is still in break mode! -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
All times are GMT +1. The time now is 07:00 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com