I am extremely new to VBA so any help is appreciated. I am trying to extract data from this website https://www.census.gov/construction/bps/txt/tb3u201601.txt. The 201601 in the url represents jan 2016. I would like to create a program that cycles through all the months until 2003 and puts all the data in an excel spreadsheet. So far I have written something that isolated the date (below) but I cannot figure out how to have it loop through the dates I need. Thanks again.
Sub Macro2()
'
' Macro2 Macro
'
'
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim str As String
str1 = "URL;https://www.census.gov/construction/bps/txt/tb3u"
str2 = "201601"
str3 = ".txt"
str = str1 & str2 & str3
With ActiveSheet.QueryTables.Add(Connection:= _
str, Destination _
:=Range("$A$2"))
.Name = "tb3u201601_4"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub