0

I have a 2 gig csv file that I want to read into an excel vba macro process one record at a time, or one datum at a time. How can I? Can I?

Community
  • 1
  • 1
user2200765
  • 21
  • 1
  • 1
  • 5

1 Answers1

1

You can use the Scripting.FileSystemObject to do that:

As a sample of how you can read in a file line by line:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\FSO\ServerList.txt", 1)
    Do Until objFile.AtEndOfStream
       strLine = objFile.ReadLine
       ... You code here ...
    Loop
objFile.Close

Just remember to add a reference to the Microsoft Scripting Runtime (where the FileSystemObject is)

How do I use FileSystemObject in VBA?

Community
  • 1
  • 1
John Bustos
  • 19,036
  • 17
  • 89
  • 151