Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > import txt


Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2010, 11:52 AM
luksky luksky is offline
Newcomer
 
Join Date: Apr 2010
Posts: 1
Default import txt


Hey I have a problem and needs your help
How to import specific lines from txt file.
How to create such a code in vba.
-Load a txt file
-Open it
-Reads for example 2 row
-And paste this line to line, for example, 3 in excel
-I will add that data in the txt file are separated by ":"
-And look more or less like
10, 30, 20-12-2010, Reva; 5

Last edited by luksky; 04-20-2010 at 12:24 PM.
Reply With Quote
  #2  
Old 04-22-2010, 06:28 AM
zebulon72 zebulon72 is offline
Regular
 
Join Date: Feb 2010
Posts: 74
Default

Hi,
there are lots of threads with similar questions in this forum, so have a look around and revert back with the code you come up with.

here is something to get you started. i suggest you get all of the text file into a spreadsheet and sort it from there. try recording a macro for text to cols, etc.

Code:
  
' get the text file.
  Open "C:\myfolder1\file1.txt" For Input As #1
    i = 1

    Do Until EOF(1)
        
        Line Input #1, mylinevar
        Cells(i, 1) = mylinevar
        i = i + 1
        
    Loop
    Close #1
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->