rimshot609
Board Regular
- Joined
- Jun 4, 2015
- Messages
- 79
I am using this Macro that copies the data in column B
and saves it to a text file with the titles in column C and if there is no text in the cells in column B it creates an emtpy text file. It works great but if the cells have special characters it gives me an error. Any suggestions?
and saves it to a text file with the titles in column C and if there is no text in the cells in column B it creates an emtpy text file. It works great but if the cells have special characters it gives me an error. Any suggestions?
Code:
Sub SendToText()
Dim cell As Range
Dim FF As Long
Dim Counter As Long
For Each cell In Range("B1", Range("C" & Rows.Count).End(xlUp))
If cell.Value <> "" Then
FF = FreeFile()
Open ThisWorkbook.Path & "\" & cell.Value & ".txt" For Output As #FF
Print #FF, cell.Offset(, 1).Text
Close #FF
Counter = Counter + 1
End If
Next cell
MsgBox Counter & " - Files sent.", , "Text files created"
End Sub