Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:53:08+00:00 2026-06-15T05:53:08+00:00

I have a VBA code with which I import a txt file into one

  • 0

I have a VBA code with which I import a txt file into one cell.
Here’s the code (it’s not that important):

Sub ReadFile()
     ' Requires a reference to Microsoft Scripting Runtime (Tools > References)
    Dim FSO As FileSystemObject
    Dim FSOFile As File
    Dim FSOStream As TextStream

    Dim Rand
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")

   Set FSO = New FileSystemObject
   Set FSOFile = FSO.GetFile("C:\Users\sdagfsgedg\Desktop\20121122.log")
   Set FSOStream = FSOFile.OpenAsTextStream(ForReading, TristateUseDefault)
   Rand = 1
   Do While Not FSOStream.AtEndOfStream
        ws.Cells(Rand, 1).Value = FSOStream.ReadAll
   Loop
End Sub

The text file 20121122.log has about 20.000 lines which are all imported in one cell. How can I split that cell into 20.000 cells (if the log has 20.000 lines). I don’t want to read the text file line by line… I want to read it all (it’s way more faster) then split every line on a separate row.

LATER EDIT:
Or if there is another solution to read the log file and paste the text as line to row (not everything in one cell as I do right now)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:53:10+00:00Added an answer on June 15, 2026 at 5:53 am

    // Code is not tested

    Sub ReadFile()
      Dim FSO As FileSystemObject
      Dim FSOFile As File
      Dim FSOStream As TextStream
    
      Dim Rand
      Dim row
      Dim ws As Worksheet
      Set ws = Worksheets("Sheet1")
    
      Set FSO = New FileSystemObject
      Set FSOFile = FSO.GetFile("C:\Users\sdagfsgedg\Desktop\20121122.log")
      Set FSOStream = FSOFile.OpenAsTextStream(ForReading, TristateUseDefault)
      Rand = 1
      Dim content As String
      Dim lines As Variant
      Dim intIndex As Integer
    
      content = FSOStream.ReadAll
      lines = split(content, Chr(10))
    
      For intIndex = LBound(lines) To UBound(lines)
        ws.Cells(Rand, 1).Value = lines(intIndex)
        Rand = Rand + 1
      Next
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VBA code which one of the line looks like this analysisSheet.Cells(i,
I have to maintain a portion of Access 2003 VBA code, which is not
I have an Excel workbook, which using VBA code that opens another workbook, copies
I have some VBA code in an Excel workbook. I have a cell which
I have a VBA code that creates a file and need to have an
I have some VBA code that needs to talk to a running c# application.
I have a method in my VBA code that needs to be assigned to
I'm not sure why my code is not working.. I have code in vba
I have a VBA Word Macro that gets words from .txt list and color
I have a VBA script that inserts long strings into Excel cells. In some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.