Posted By

buglilorenzo on 10/18/17


Tagged

import txt read excel


Versions (?)

Read data from txt files


 / Published in: Visual Basic
 

Read data from TXT files to import them in Excel environment

  1. Sub ImportFromText(x As Integer, y As Integer, filename As String)
  2. Dim base As String
  3. Dim WS As Worksheet
  4. Dim WB As Workbook
  5.  
  6. Set WB = ThisWorkbook
  7. Set WS = WB.Worksheets("Results")
  8.  
  9. base = ThisWorkbook.PATH
  10. file_path = base & "\output\" & filename
  11. Open file_path For Input As #1
  12. r = x
  13. Do Until EOF(1)
  14. Line Input #1, Data
  15. v = Split(Data, vbTab)
  16. For i = 0 To 3 Step 1
  17. If r = x Then
  18. WS.Range("AA2").Offset(r, y + i) = v(i)
  19. Else
  20. WS.Range("AA2").Offset(r, y + i) = Round(CDbl(v(i)), 5)
  21. End If
  22. Next i
  23. r = r + 1
  24. Loop
  25. Close #1
  26. End Sub
  27.  
  28. Sub import_modified_files()
  29. Call ImportFromText(0, 0, "Stream number 1 - stream function 0,0000.txt")
  30. Call ImportFromText(0, 4, "Stream number 2 - stream function 0,2500.txt")
  31. Call ImportFromText(0, 8, "Stream number 3 - stream function 0,5000.txt")
  32. Call ImportFromText(0, 12, "Stream number 4 - stream function 0,7500.txt")
  33. Call ImportFromText(0, 16, "Stream number 5 - stream function 1,0000.txt")
  34. End Sub

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: sarahemi on November 3, 2017

Txt files and description plays an important role in making search engine crawl your site easily.. .txt files are caught and crawled by the Google spiders, in the result, the Google rankings are improved if we have put in the right and targeted keywords in the .txt format. Our experts at Best SEO Company are guided and directed to optimize the site in such organic way that the search engines could recognize its content easily and quickly.

Posted By: bawajeeB on October 29, 2018

best seo service in pakistan SEO services in Islamabad

Posted By: bawajeeB on November 1, 2018

?BBL Today Match Prediction

Posted By: bawajeeB on November 1, 2018

?today match prediction

Posted By: rosejacob on January 31, 2019

Very good, I think I found the knowledge I needed. I will see and refer some information in your post. thank you. business setup in sharjah freezone

Posted By: Robsarah on August 5, 2019

Creating a text file this way opens your default text editor with a blank text file on your Machine.

Regards Ron from web design company Sydney

Posted By: aaqilfaraj on August 20, 2019

Awesome post buddy ?

Regards AaqilFaraj from Trademark registration service dubai

Posted By: hannahsmith on August 21, 2019

Very good, I think I found the knowledge I needed. I will see and refer some information in your post. thank you

SEO company

Posted By: gexhost on September 17, 2019

Gexhost is the trusted web hosting company in Pakistan who provide Pakistan based web hosting services across the World. Our Secure servers and reliable web hosting packages are suitable for business. we provide affordable web hosting with free domain registration. Gexhost Support team active 24/7 for solving your web hosting problem. if you think you need a good Pakistan web hosting company then contact us! Web Hosting Pakistan

You need to login to post a comment.