I need help, my code will not pull data into the new sheet that it creates from the website. It comes up as blank. It is really frustrating. The query table will not pull the data in after I assigned the string variable "counties" as a website address. I have looked all over the internet and haven't found the answer of how to fix this.
counties = Range("HTML").Offset(x, 0) shows up to equal 08/08001.html which is part of the website address.
Sub Macro6()
Dim x As Integer
Dim counties As String
For x = 1 To 3
Sheets("RawData").Select
counties = Range("HTML").Offset(x, 0)
Sheets.Add.Name = "DataTemp"
With ActiveSheet.QueryTables.Add(Connection:="URL;http://quickfacts.census.gov/qfd/states/" & counties & ".html", Destination:=Range("$A$1"))
.Name = "08001"
.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,4,5"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
End With
'This part moves the data from the newly created "DataTemp" sheet into the "Demographics" sheet.
Columns("A:B").Select
ActiveWindow.ScrollColumn = 2
Range("A:B,D:D").Select
Range("D1").Activate
Selection.ClearContents
Range("C1:C63").Select
Selection.Copy
Sheets("Demographics").Select
Cells(6, x + 2).Select
ActiveSheet.Paste
Columns("C:C").EntireColumn.AutoFit
ActiveSheet.Previous.Select
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
Next x
End Sub