Even tho I have put in the message box enter the date in the format dd/mm/yyyy some people cannot do that, so can anyone help me with some error handling, I have never done any error handling before so if anyone can point me at a good source to learn error handling that would be helpful too.
The code basically imports a text file that has all the data in it alread and then takes the user to a view of it made to look pretty!
The code basically imports a text file that has all the data in it alread and then takes the user to a view of it made to look pretty!
Code:
Sub DailyStats()
Dim Dateinput As Date
Dateinput = Format(Dateinput, "dd/mm/yyyy")
Dateinput = InputBox("Enter date (dd/mm/yyyy)")
Range("IV2").Select
Selection.ClearContents
ActiveCell = Dateinput
Range("A1").Select
'Get Day
Sheets("Day Import").Select
Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\team\" & "D" & Sheets("Menu").Range("IV3").Value & ".txt", _
Destination:=Range("A1"))
.Name = "Day import"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.Refresh BackgroundQuery:=False
End With
Range("A1").Select
Sheets("Day view").Select
Range("B38").Select
ActiveCell.FormulaR1C1 = "These are the daily stats for " & Dateinput
Range("A1").Select
End Sub