![]() |
Import and Split CSV
Try the following code:
Sub AAA() Dim FNum As Integer Dim RowNdx As Long Dim FName As String Dim V As Variant Dim WS As Worksheet Dim ColNdx As Long Dim Arr As Variant FNum = FreeFile FName = "H:\Temp2\Test.txt" RowNdx = 1 Set WS = Worksheets(1) Open FName For Input As FNum Do Until EOF(FNum) Line Input #1, V Arr = Split(V, ",") For ColNdx = 0 To UBound(Arr) WS.Cells(RowNdx, ColNdx + 1) = Arr(ColNdx) Next ColNdx ColNdx = 1 RowNdx = RowNdx + 1 If RowNdx = Rows.Count Then RowNdx = 1 With ActiveWorkbook.Worksheets Set WS = .Add(after:=.Item(.Count)) End With End If Loop Close FNum End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mpeplow" wrote in message ... I need to import a csv file into excel but the file is way too big to load onto a single speadsheet. How would have excel import the file, then once a sheet is full, create a new sheet and continue the import? :confused: -- mpeplow ------------------------------------------------------------------------ mpeplow's Profile: http://www.excelforum.com/member.php...o&userid=34812 View this thread: http://www.excelforum.com/showthread...hreadid=545694 |
All times are GMT +1. The time now is 01:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com