You macro needs a little more work. This worked fine for me:
'My macro starts here
Sub MAKEXLS()
Dim sname As String
Dim sPath As String
Dim XLSBHAVCOPY As Workbook
sPath = "D:\INVESTMENTS\CSV\"
sPath1 = "D:\INVESTMENTS\xls\"
If Right(sPath, 1) <> "\" Then
sPath = sPath & "\"
End If
If Right(sPath1, 1) <> "\" Then
sPath = sPath1 & "\"
End If
sname = Dir(sPath & "*.csv")
Do While sname <> ""
' open the workbook
Set XLSBHAVCOPY = Workbooks.Add()
' open csv, write data to workbook
ImportTextFile sPath & sname, ","
' save the a file as xls
sname = Left(sname, Len(sname) - 4)
With XLSBHAVCOPY
.SaveAs Filename:=sPath1 & sname, _
FileFormat:=xlWorkbookNormal
.Close Savechanges:=True ' already saved
End With
sname = Dir()
Loop
End Sub
'my Macro ends above
'Chip Pearson code starts here
Public Sub ImportTextFile(FName As String, Sep As String)
Dim RowNdx As Integer
Dim ColNdx As Integer
Dim TempVal As Variant
Dim WholeLine As String
Dim Pos As Integer
Dim NextPos As Integer
Dim SaveColNdx As Integer
Application.ScreenUpdating = False
'On Error GoTo EndMacro:
SaveColNdx = ActiveCell.Column
RowNdx = ActiveCell.Row
Open FName For Input Access Read As #1
While Not EOF(1)
Line Input #1, WholeLine
If Right(WholeLine, 1) <> Sep Then
WholeLine = WholeLine & Sep
End If
ColNdx = SaveColNdx
Pos = 1
NextPos = InStr(Pos, WholeLine, Sep)
While NextPos >= 1
TempVal = Mid(WholeLine, Pos, NextPos - Pos)
Cells(RowNdx, ColNdx).Value = TempVal
Pos = NextPos + 1
ColNdx = ColNdx + 1
NextPos = InStr(Pos, WholeLine, Sep)
Wend
RowNdx = RowNdx + 1
Wend
EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True
Close #1
End Sub