@apo I later thought of having a folder on desktop of users. So, whatever the users desktop location may be, should create folder and save the text file there. I tried this using ur code.
Private Sub CommandButton1_Click()
Dim strDir As String, fName As String, fPath As String, myArea
strDir = "C:\Users\" & Environ$("Username") & "\Desktop\FFolder\"
fName = Sheets("Sheet2").Range("A1").Value
fPath = strDir
If Dir(strDir, vbDirectory) = "" Then
MkDir strDir
Else
MsgBox "Directory exists."
End If
With CreateObject("Scripting.FileSystemObject").CreateTextFile(fPath & fName & ".txt", True)
For Each myArea In Sheets("Sheet2").Range("B1:B" & Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row).SpecialCells(2).Areas
.writeline Join(Application.Transpose(myArea), vbCrLf)
Next myArea
End With
MsgBox "File Saved to: " & fPath
End Sub
Thanks for your code and much appreciate it.
Bookmarks