Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Format as text

Hi, i'm trying to import a text file into xls, and i've got it all done, but
have a litle problem with this:

Open Filename For Input As #1
Do While Not EOF(1)

FicheiroActual.Activate

Input #1, Line$

ColunaA$ = Mid$(Line$, 1, 1)
ColunaB$ = Mid$(Line$, 2, 14)
ColunaC$ = Mid$(Line$, 15, 17)
ColunaD$ = Mid$(Line$, 32, 17)

Worksheets("Sheet1").Cells(x, 1).Value = ColunaA$
Worksheets("sheet1").Cells(x, 2).Value = ColunaB$
Worksheets("sheet1").Cells(x, 3).Value = ColunaC$
Worksheets("sheet1").Cells(x, 4).Value = ColunaD$

x = x + 1

Loop
Close #1

Question: the ColunaB$ should be set as text, how can i format the field?

Thank you very much
Pedro Costa
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Format as text

Hi
Format the destination cell as text first

Worksheets("sheet1").Cells(x, 2).NumberFormat = "@"

regards
Paul

On Mar 23, 9:10 am, Pedro Costa
wrote:
Hi, i'm trying to import a text file into xls, and i've got it all done, but
have a litle problem with this:

Open Filename For Input As #1
Do While Not EOF(1)

FicheiroActual.Activate

Input #1, Line$

ColunaA$ = Mid$(Line$, 1, 1)
ColunaB$ = Mid$(Line$, 2, 14)
ColunaC$ = Mid$(Line$, 15, 17)
ColunaD$ = Mid$(Line$, 32, 17)

Worksheets("Sheet1").Cells(x, 1).Value = ColunaA$
Worksheets("sheet1").Cells(x, 2).Value = ColunaB$
Worksheets("sheet1").Cells(x, 3).Value = ColunaC$
Worksheets("sheet1").Cells(x, 4).Value = ColunaD$

x = x + 1

Loop
Close #1

Question: the ColunaB$ should be set as text, how can i format the field?

Thank you very much
Pedro Costa



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Format as text

or:

Worksheets("sheet1").Columns(2).NumberFormat = "@"

This could just go after the loop is completed

J



On Mar 23, 9:26 am, wrote:
Hi
Format the destination cell as text first

Worksheets("sheet1").Cells(x, 2).NumberFormat = "@"

regards
Paul

On Mar 23, 9:10 am, Pedro Costa
wrote:



Hi, i'm trying to import a text file into xls, and i've got it all done, but
have a litle problem with this:


Open Filename For Input As #1
Do While Not EOF(1)


FicheiroActual.Activate


Input #1, Line$


ColunaA$ = Mid$(Line$, 1, 1)
ColunaB$ = Mid$(Line$, 2, 14)
ColunaC$ = Mid$(Line$, 15, 17)
ColunaD$ = Mid$(Line$, 32, 17)


Worksheets("Sheet1").Cells(x, 1).Value = ColunaA$
Worksheets("sheet1").Cells(x, 2).Value = ColunaB$
Worksheets("sheet1").Cells(x, 3).Value = ColunaC$
Worksheets("sheet1").Cells(x, 4).Value = ColunaD$


x = x + 1


Loop
Close #1


Question: the ColunaB$ should be set as text, how can i format the field?


Thank you very much
Pedro Costa- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Format as text

Thank you very much, it worked just fine

Best regards
Pedro Costa

"WhytheQ" escreveu:

or:

Worksheets("sheet1").Columns(2).NumberFormat = "@"

This could just go after the loop is completed

J



On Mar 23, 9:26 am, wrote:
Hi
Format the destination cell as text first

Worksheets("sheet1").Cells(x, 2).NumberFormat = "@"

regards
Paul

On Mar 23, 9:10 am, Pedro Costa
wrote:



Hi, i'm trying to import a text file into xls, and i've got it all done, but
have a litle problem with this:


Open Filename For Input As #1
Do While Not EOF(1)


FicheiroActual.Activate


Input #1, Line$


ColunaA$ = Mid$(Line$, 1, 1)
ColunaB$ = Mid$(Line$, 2, 14)
ColunaC$ = Mid$(Line$, 15, 17)
ColunaD$ = Mid$(Line$, 32, 17)


Worksheets("Sheet1").Cells(x, 1).Value = ColunaA$
Worksheets("sheet1").Cells(x, 2).Value = ColunaB$
Worksheets("sheet1").Cells(x, 3).Value = ColunaC$
Worksheets("sheet1").Cells(x, 4).Value = ColunaD$


x = x + 1


Loop
Close #1


Question: the ColunaB$ should be set as text, how can i format the field?


Thank you very much
Pedro Costa- Hide quoted text -


- Show quoted text -




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
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Excel Worksheet Functions 6 June 2nd 09 08:14 PM
Change Date Format to Specific Text Format When Copying [email protected] Excel Discussion (Misc queries) 4 December 23rd 08 03:43 PM
how to format a Docmd to pull in an Access file in Text format Campbellj4 Excel Programming 0 November 2nd 05 04:22 PM
how to format a Docmd to pull in an Access file in Text format Campbellj4[_2_] Excel Programming 0 November 2nd 05 04:22 PM
how to format excel format to text format with separator "|" in s. azlan New Users to Excel 1 January 31st 05 12:57 PM


All times are GMT +1. The time now is 10:28 PM.

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"