Below is my code, but what I need is VBA to get a part of the connection url from a cell.
I've got a list of IDnumbers f.ex. 12345, 23456, 34567 etc. in cell "B7" and I need the connection url to be formed like ->
http://www.eliteprospects.com/player.php?player= & "IDnumber". The IDnumbers are in a data validation list and I need excel/VBA get that number and put it after the "XXXXXphp?player=" to refresh the query every time that number is changed.
If that isn't possible i've got also a list of full url's so forming that connection url from two parts is not mandatory. Only thing that is mandatory is to get the connection url from a data validation list as a whole or combined from different cells.
And please dont tell me to create .iqy files as they are not working. And if someone gives me a string of code to get the iqy-files to work perfectly, that would force me to create like 1500 different iqy's and that is something i wont do.
The only way I can get Excel to import the right tables is VBA table query. The tables are "dynamically scripted" so Excel's web query browser does NOT import those tables. Also tried and tested iqy-files and they perform exactly like web query browser and imports nothing I ask it to.
My code:
Sub Basic_Web_Query()
Application.Wait (Now + TimeValue("0:00:01"))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.eliteprospects.com/team.php?team=43", Destination:=Range("$A$1"))
.Name = "q?s=goog_2"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "14"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
I've got a list of IDnumbers f.ex. 12345, 23456, 34567 etc. in cell "B7" and I need the connection url to be formed like ->
http://www.eliteprospects.com/player.php?player= & "IDnumber". The IDnumbers are in a data validation list and I need excel/VBA get that number and put it after the "XXXXXphp?player=" to refresh the query every time that number is changed.
If that isn't possible i've got also a list of full url's so forming that connection url from two parts is not mandatory. Only thing that is mandatory is to get the connection url from a data validation list as a whole or combined from different cells.
And please dont tell me to create .iqy files as they are not working. And if someone gives me a string of code to get the iqy-files to work perfectly, that would force me to create like 1500 different iqy's and that is something i wont do.
The only way I can get Excel to import the right tables is VBA table query. The tables are "dynamically scripted" so Excel's web query browser does NOT import those tables. Also tried and tested iqy-files and they perform exactly like web query browser and imports nothing I ask it to.
My code:
Sub Basic_Web_Query()
Application.Wait (Now + TimeValue("0:00:01"))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.eliteprospects.com/team.php?team=43", Destination:=Range("$A$1"))
.Name = "q?s=goog_2"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "14"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub