Smartgambler
Pro-Punter

Go Back   OZmium Sports Betting and Horse Racing Forums > Public Forums > General Topics
User Name
Password
Register FAQ Search Today's Posts Mark all topics as read

To advertise on these
forums, e-mail us.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 24th July 2011, 12:46 PM
Shaun Shaun is offline
Member
 
Join Date: Jan 1970
Location: Western Australia
Posts: 3,456
Default Excel Help

I need some help with web query, i am importing pages from Cyberhorse but having issues with formatting, here is a page from today.

http://formguide.cyberhorse.com.au/...=Coffs&raceno=5

When i import the page the formats for some of the Distance,track and going get all messed up, seams if the number of starts is over 10 it changes the format, i have tried a few things with no success so am after some help from more experienced with excel.
Reply With Quote
  #2  
Old 24th July 2011, 05:28 PM
4legs 4legs is offline
Member
 
Join Date: Mar 2009
Posts: 96
Default

Shaun, if you email me your web query I can have have a quick look at it and see if I can spot any problems .. Fred
Reply With Quote
  #3  
Old 24th July 2011, 06:30 PM
The Elk The Elk is offline
Member
 
Join Date: Sep 2008
Posts: 28
Default

Shaun,
Is this the info you are trying to extract? (stats from 1st runner Blinkin Easy)
Quote:
Distance: 13:2-1-3
Track: 3:0-0-0
Good: 31:5-5-3
Dead: 9:3-0-2
...etc
I'm not quite sure what you mean by "it gets all messed up over 10 starts"?

My excel web queries are a bit rusty but vb2010 is pretty close:

1. extract Dis = "13:2-1-3" using Instr()
2. Career()=Split(Dis,":") giving Career(0)="13" & Career(1)="2-1-3"
3. Place()=split(Career(1),"-") so Place(0)="2" Place(1)="1" Place(2)="3"


Is this what you are trying to do and having troubles when runs at distance > 9 , Good=31...etc?

Probably need a little more info to give any further help

cheers
Reply With Quote
  #4  
Old 24th July 2011, 07:00 PM
Shaun Shaun is offline
Member
 
Join Date: Jan 1970
Location: Western Australia
Posts: 3,456
Default

The extraction is not the problem the problem is it wants to sometimes format the number as a date, even if i have the sheet formatted as text when i import the new sheet it just goes back.
Reply With Quote
  #5  
Old 24th July 2011, 10:14 PM
The Elk The Elk is offline
Member
 
Join Date: Sep 2008
Posts: 28
Default

Aaaaaahhhh, now I understand - can you change the dashes to dots/periods or anything other than dashes so that excel does not recognise it as a date

cheers
Reply With Quote
  #6  
Old 4th August 2011, 11:36 PM
Shaun Shaun is offline
Member
 
Join Date: Jan 1970
Location: Western Australia
Posts: 3,456
Default

I have found a solution to this problem thanks to a user on the Gruss forum, he uses some macros to change 10:1-2-0 to 10::1-2-0 the double :: confuses excel and stops it changing to a date format.

I will post the macro but i don't totally understand it but it works, there are 3 parts to the macro.

The part in red in macro 3 is what he has added to my macro.


Forgot to mention what ever he has done has changed the import time from 30 seconds a race to 5 seconds.

Code:
Public Function ExecuteWebRequest(url As String) As String Dim oXHTTP As Object Set oXHTTP = CreateObject("MSXML2.XMLHTTP") oXHTTP.Open "GET", url, False oXHTTP.send ExecuteWebRequest = oXHTTP.responseText Set oXHTTP = Nothing End Function


Code:
Public Function outputtext(text As String) Dim MyFile As String, fnum As String MyFile = ThisWorkbook.Path & "\temp.txt" fnum = FreeFile() Open MyFile For Output As fnum Print #fnum, text Close #fnum End Function


Code:
Sub form() Sheets("Form").Select Sheets("Form").Range("B1:J1000").Select Selection.ClearContents Columns("B:J").Select Selection.NumberFormat = "@" formhtml = ExecuteWebRequest(ThisWorkbook.Sheets("Data").Range("A1").Value) formhtml = Replace(formhtml, ":", "::") outputtext (formhtml) Set temp_qt = ThisWorkbook.Sheets("Form").QueryTables.Add(Connection:= _ "URL;" & ThisWorkbook.Path & "\temp.txt" _ , Destination:=ThisWorkbook.Sheets("Form").Range("B1")) With temp_qt .Name = "test" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlOverwriteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlAllTables .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = True .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With Set temp_qt = Nothing Kill ThisWorkbook.Path & "\temp.txt" If ThisWorkbook.Connections.Count > 0 Then ThisWorkbook.Connections.Item(ThisWorkbook.Connect ions.Count).Delete Columns("B:J").Select Selection.Copy Application.DisplayAlerts = False Sheets("Data").Select Range("AA1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Columns("AA:AA").Select Application.CutCopyMode = False Selection.TextToColumns Destination:=Range("AA1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _ Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _ :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _ Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _ ), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1)), _ TrailingMinusNumbers:=True Columns("AC:AC").Select Selection.TextToColumns Destination:=Range("AC1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _ Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _ :=Array(1, 5), TrailingMinusNumbers:=True Application.DisplayAlerts = True Range("A1").Select End Sub

Last edited by Shaun : 4th August 2011 at 11:41 PM.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump



All times are GMT +10. The time now is 06:35 AM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
©2008 OZmium Pty. Ltd. All rights reserved . ACN 091184655