Dim oldText As String
Dim rowCount As Long
Dim colCount As Long
Dim allData As Variant
Dim cellFormat As String
rowCount = 1 'set to row you want imported data to start from
colCount = 1 'set to col you want imported data to start from
fName = Application.GetOpenFilename 'find your file
Open fName For Input As #1 'open it
While Not EOF(1) 'loop till end of the file
Line Input #1, oldText 'read in a line of text
allData = Split(oldText, ",") 'split into bits based on the comma (,) positions
For i = 0 To UBound(allData, 1) 'work out how many bits of data you have
Select Case Left(allData(i), 1) 'check if the leading chr is 0
Case "0" 'check if the leading chr is 0
If Mid(allData(i), 2, 1) = "." Then 'if a decimal number leave format as general
With Cells(rowCount, colCount + i)
.NumberFormat = "General"
End With
Else 'if not a decimal number set format to Text
With Cells(rowCount, colCount + i)
.NumberFormat = "@"
.Font.ColorIndex = 5 'give it a different colour
End With
End If
Case Chr(34) 'check for any " chrs around text and strip out
allData(i) = Mid(allData(i), 2, Len(allData(i)) - 2)
With Cells(rowCount, colCount + i) 'change the font style for text
.NumberFormat = "@"
.Font.Name = "Antique Olive Roman"
.Font.FontStyle = "Italic"
.Font.Size = 10
.Font.Strikethrough = False
.Font.Superscript = False
.Font.Subscript = False
.Font.OutlineFont = False
.Font.Shadow = False
.Font.Underline = xlUnderlineStyleNone
.Font.ColorIndex = 3
End With
End Select
Cells(rowCount, colCount + i).Value = allData(i) 'copy new data to sheet
Next i
rowCount = rowCount + 1 'increment row counter
Wend
Close #1 'don't forget to close the file