noslenwerd
Board Regular
- Joined
- Nov 12, 2019
- Messages
- 85
- Office Version
- 365
Hello,
New to the forum. I've learned a lot just reading.
Wondering if someone can help me with the VBA code below. It DOES save the whole worksheet to a text file, but I would like it to also
New to the forum. I've learned a lot just reading.
Wondering if someone can help me with the VBA code below. It DOES save the whole worksheet to a text file, but I would like it to also
- Only save content in Column K
- Skip over blank cells in Column K
Code:
Sub saveText()
ActiveWorkbook.SaveAs FileName:= _
ThisWorkbook.Path & "\textfile-" & Format(Now, "ddmmyy-hhmmss") & ".txt", FileFormat:=xlText, _
CreateBackup:=False
End Sub
Sub saveText2()
Dim FileName As String, lineText As String
Dim myrng As Range, i, j
FileName = ThisWorkbook.Path & "\isell-notes-" & Range("B6") & Format(Now, "mmddyy-hhmmss") & ".txt"
Open FileName For Output As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL]
Set myrng = Range("data")
For i = 1 To myrng.Rows.Count
For j = 1 To myrng.Columns.Count
lineText = IIf(j = 1, "", lineText & ",") & myrng.Cells(i, j)
Next j
Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , lineText
Next i
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL]
End Sub