Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing Text to Excel


Greetings,

I have to figure out a way to import only 10 lines of text from a text
file.

Any suggestions?

Cheers
Aurbo


--
Aurbo
------------------------------------------------------------------------
Aurbo's Profile: http://www.excelforum.com/member.php...o&userid=29079
View this thread: http://www.excelforum.com/showthread...hreadid=488059

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing Text to Excel


Hello Aurbo,

Here is a macro that will open a text file and copy it line by line to
the active worksheet. Place this code in a VBA module to run it. You
didn't say if it was the first 10 lines of the file or not, but this is
the basic code to copy the text to the worksheet.

Calling the macro:
CopyTextToWorksheet ("Your file's name", "worksheet cell")

Sub CopyTextToWorksheet(ByVal FileToOpen As String, ByVal StartCell As
String)
Dim Data
Dim FF As Integer
Dim FN As String
Dim Row As Integer
Dim Rng As Range

FF = FreeFile
FN = FileToOpen
Set Rng = ActiveSheet.Range(StartCell)

Open FN For Input As #FF
Do While Not EOF(FF)
Input #FF, Data
Rng.Offset(Row, 0).Value = Data
Row = Row + 1
Loop
Close #FF
End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=488059

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing Text to Excel


You put your question in the programming forum, but just in case you
need to do it only once, here is a procedu
File-Open (or CTRL+O)
Files of Type to be Text-files
select if you have a delimiter or if you will just have each line in
one cell.

NSV


--
nsv
------------------------------------------------------------------------
nsv's Profile: http://www.excelforum.com/member.php...o&userid=26500
View this thread: http://www.excelforum.com/showthread...hreadid=488059

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Text from Outlook into Excel Daren Excel Discussion (Misc queries) 5 October 12th 08 12:55 PM
importing text and placed graphics into excel spanishDave Excel Discussion (Misc queries) 0 August 4th 08 12:21 PM
Importing Text File into Excel Martin Excel Discussion (Misc queries) 1 April 2nd 06 02:48 PM
importing text file in excel UT Excel Discussion (Misc queries) 0 March 16th 06 10:20 PM
Importing text into Excel... Tim M Excel Discussion (Misc queries) 3 March 2nd 06 05:08 PM


All times are GMT +1. The time now is 04:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"