Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing Cell Content To Text File As It Seems! 1

Status
Not open for further replies.

MrProgrammer

Programmer
Feb 1, 2002
41
TR
Hi everybody,
I want to ask something. I have an excel file which contains some records with special formats. For example one field has "0000000000" custom format which means even I enter 100 to that cell's value, it is seen as 0000000100.

Here is my problem. I want to concatenate each row's fields and write each record into a text file line by line. when concatenating fileds, I use & operator.

For example;

Open "BLABLA.TXT" For Output As #1
rowtext = Range("A2").Value & Range("B2").Value .....
Write #1, rowtext
Close #1

Here is the problem: cell's values are taken without their formats. For example A2 cell contains value 100 and its format is 0000000000. So I want to write it as 0000000100 into the text file. But Range("A2").Value returns just 100 not 0000000100. Is there a short way of doing this?

Thanks in advance.
 
You can use Text property instead of Value:
[tt]rowtext = Range("A2").Text & Range("B2").Text .....[/tt]

combo
 
In fact, I tried that method. But I think I missed some parts so it did'nt work. Now I did it more carefully and it works. Thank you very much combo!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top