I have this code that helps with import of text files into excel. It intended to be a workaround for Excel not being able to deal with numbers longer than 15 characters.
I am trying to figure out a way to change this code .TextFileColumnDataTypes = Array(1, 2, 1, 1, 1, 1) into something that would go through a file an automatically check if a column contains numbers 16 characters or longer and automatically switch them to text values in order to preserve their formatting.
Sub Text_import()
Dim Ret
Ret = Application.GetOpenFilename("CSV Files (*.csv), *.csv")
If Ret <> False Then
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & Ret, Destination:=Range("$A$1"))
.Name = "Sample"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 2, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End If
End Sub