Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Importing Text from Outlook into Excel | Excel Discussion (Misc queries) | |||
importing text and placed graphics into excel | Excel Discussion (Misc queries) | |||
Importing Text File into Excel | Excel Discussion (Misc queries) | |||
importing text file in excel | Excel Discussion (Misc queries) | |||
Importing text into Excel... | Excel Discussion (Misc queries) |