Copy the one column range from excel to notepad

123raajesh

New member
Joined
May 1, 2014
Messages
7
Reaction score
0
Points
0
Hello,

Is there a way to copy from excel to a notepad file.

1 The macro would run from sheet1.
2 Create folder on desktop. If folder exists do not create.
3 Create notepad file name mentioned in sheet2 A1. Copy content of sheet2 range B2:B2500, to this file. If this text file exists overwrite the file, without any prompt.

Please help with simplest way to achieve.

Thanks in advance.
 
Code:
Sub ColumnToTxt()
    Dim x As String
    x = Sheet2.Range("B2:B2500").Address
    fname = Sheet2.Range("A1")
    Open "C:\users\yourname\desktop\" & fname For Output As #1
    Print #1, Join(Evaluate("transpose(" & x & ")"), vbCrLf)
    Close #1
End Sub
 
Back
Top