Hello,
I have a problem changing part of my URL in the web query. It doesn't give me any error back, but it doesn't show my data as well. Something must be wrong with rngURL.Value I guess. In A1 there is "Latvia". Here is my code:
Sub Macro1()
Dim rngURL As Range
Dim rngOutput As Range
Set rngOutput = Range("C1")
For Each rngURL In Range("A1:A2").Cells
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.erepublik.com/en/country/economy/ & rngURL.Value", Destination:=rngOutput)
.Name = rngURL.Value
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "3"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Set rngOutput = rngOutput.Offset(1, 0)
Next
End Sub
Bookmarks