Writing to a file from excel

  • Thread starter Thread starter Cesar Zapata
  • Start date Start date
C

Cesar Zapata

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..
 
cell1.value & " + " & cell3.value & " + " & cell4.value

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

HTH, Greg
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top