hi..

im writing a macro in Excel to copy a selected roe into a text file. i ve taken a button on a sheet and when user clicks on the button the selected row (only selected row) should b copied into a file on c: seperated with ","...

ive written a code wher the data is bein copied but it is not bein written into the text file. following is the code..

Dim myrow As Integer
Dim appwd As Object
myrow = ActiveWindow.RangeSelection.Row
Rows(myrow).Select
Selection.Copy

now aftr this code i wnt to copy the data into the text file seperated with ","...

can anybody help me???? its reli urgent...

thanks for the help...

hi, try this...

Sub create_txt()
Dim fso, ts As Object
Dim lastcol, i As Integer
Dim x  As Variant


Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.CreateTextFile("c:\TheFile.txt", True)
    
lastcol = Cells(3, Columns.Count).End(xlToRight).Column

For i = 1 To lastcol

 x = Cells(3, i)

    If x = vbNullString Then
        Exit For
          Else
       ts.WriteLine x
    End If
    
Next

 ts.Close
 Set ts = Nothing
 
End Sub

:S Can any one give me the macro to extract some particular data from a text file to excel

hey i also wanted d same thing.but in a different format..js tell me if u get any solution ok..

hey..
this code didnt worked out..bt i have solved the problem.
well..thanks for the help.

This question has already been answered. Start a new discussion instead.