ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Writing to a file from excel (https://www.excelbanter.com/excel-programming/313671-writing-file-excel.html)

Cesar Zapata[_2_]

Writing to a file from excel
 
Hi,

need help with the following.
I have cell1 cell3 cell 4 selected then need to run a macro that will write
the values of the the selected cells to a file in the following format.


copy cell1.value + cell3.value + cell4 C:\docs\Bigfile.txt

I have all except that I dont know how to get it written the cell value
followed by a "+" then the next selected cell value...also I dont need the
last cell to be followed by a + sign

I will really appreciate any help..



Greg Koppel

Writing to a file from excel
 
cell1.value & " + " & cell3.value & " + " & cell4.value

You may have to assign this to a variable before writing to the file.

HTH, Greg

"Cesar Zapata" wrote in message
...
Hi,

need help with the following.
I have cell1 cell3 cell 4 selected then need to run a macro that will

write
the values of the the selected cells to a file in the following format.


copy cell1.value + cell3.value + cell4 C:\docs\Bigfile.txt

I have all except that I dont know how to get it written the cell value
followed by a "+" then the next selected cell value...also I dont need the
last cell to be followed by a + sign

I will really appreciate any help..





Tom Ogilvy

Writing to a file from excel
 
Sub Tester1()
sStr = ""
For Each cell In Selection
sStr = sStr & cell.Value & " + "
Next
sStr = Left(sStr, Len(sStr) - 3)

Open "C:\docs\Bigfile.txt" For Output As #1
Print #1, sStr
Close #1
End Sub

--
Regards,
Tom Ogilvy

"Cesar Zapata" wrote in message
...
Hi,

need help with the following.
I have cell1 cell3 cell 4 selected then need to run a macro that will

write
the values of the the selected cells to a file in the following format.


copy cell1.value + cell3.value + cell4 C:\docs\Bigfile.txt

I have all except that I dont know how to get it written the cell value
followed by a "+" then the next selected cell value...also I dont need the
last cell to be followed by a + sign

I will really appreciate any help..






All times are GMT +1. The time now is 10:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com