How to extract range of cells into text file

Hi

I have list of numbers I want to extract into a text file in this attached format:

'654321354','654654','654654'
extract numbers
a500505077Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gplanaCommented:
Just use the "save as" option and selecte "CSV" as the format.

A CSV file is a text file where fields are separated by a ; and rows by an end of line.

Hope it helps. Regards.
a500505077Author Commented:
I tried it , it is not helpful
gplanaCommented:
when generated, try to change the extension of the file, or just open the file with notepad; because if not, Excel is the one who opens the .CSV file by default and it interprets the cells, so you will be the same as opening the .xls file.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

a500505077Author Commented:
format am looking for :

'321654','63541654','654654'....etc

try it.
NorieAnalyst Assistant Commented:
Are all the values in one cell, eg C1, separated by a line break?

Or are they in multiple cells going down column C starting in row 1?

Whichever it is you here's code for both
' Numbers all in one cell

Sub ExportNumbers1()
Dim strFileName As String
Dim arrNums
Dim FF As Long

    strFileName = "C:\Test\NumberExport1.txt"

    FF = FreeFile()

    Open strFileName For Output As FF

    arrNums = Split(Range("C1").Value, Chr(10))

    Print #FF, Join(arrNums, ",")

    Close #FF

End Sub

Open in new window



' Numbers in multiple cells in column C

Sub ExportNumbers2()
Dim strFileName As String
Dim arrNums
Dim FF As Long

    strFileName = "C:\Test\NumberExport2.txt"

    FF = FreeFile()

    Open strFileName For Output As FF

    arrNums = Application.Transpose(Range("C1", Range("C" & Rows.Count).End(xlUp)).Value)

    Print #FF, Join(arrNums, ",")

    Close #FF

End Sub

Open in new window

a500505077Author Commented:
Hi Nori,

Values are in one column. I tried first code but gave me blank text file.
Book2.xlsx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gplanaCommented:
I think my answer is very simple and it will solve the problem if you just change rows by columns. There is an Excel option for doing this. Or you can just copy the values, and use the "Paste special" option by selecting the "transpose" option.
a500505077Author Commented:
good
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.