hi
If you want to export data of any col to notepad.
Here is the code it will export data of col b of sheet to notepad.
create any text file and write its location in MyFile =
Sub create_txtfile()
MyFile = "C:\Documents and Settings\ashish\Desktop\ashish.txt"
'set and open file for output
fnum = FreeFile()
Open MyFile For Output As fnum
For i = 1 To Sheets(1).Range("a65356").End(xlUp).Row
'Write #fnum,Sheets(1).Cells(i, 2).Value
Print #fnum, Sheets(1).Cells(i, 2).Value
Next i
Close #fnum
End Sub
or if you want to append to existing txt file use this
Sub create_txtfile()
MyFile = "C:\Documents and Settings\achamanlalko\Desktop\ashish.txt"
'set and open file for output
fnum = FreeFile()
Open MyFile For Append As #1
Write #1,
For i = 3 To Sheets(1).Range("a65356").End(xlUp).Row
'Write #fnum,Sheets(1).Cells(i, 2).Value
Print #1, Sheets(1).Cells(i, 2).Value
Next i
Close #fnum
End Sub
Subscribe to:
Post Comments (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
If you want to copy the data from pdf file to Excel. Sub method1_using_sendkey() Dim task ' open the file ' change the path of ...
-
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
to save a sheet in notepad check this
ReplyDeletehttp://www.compshack.com/visual-basic/save-file-using-visual-basic-excel-macro