行1-300のすべてのテキストをシートからコピーし、それをUTF-8形式のテキストファイルに保存する小さなコードがあります。テキストを含む行からテキストのみをコピーするように拡張したい。私はVBAの人ではありません、これについて私を助けてください。
Sub tgr()
Dim oStream As Object
Dim sTextPath As String
Dim sText As String
Dim rIndex As Long, cIndex As Long
sTextPath = Application.GetSaveAsFilename("import.txt", "Text Files, *.txt")
If sTextPath = "False" Then Exit Sub
For rIndex = 1 To 300
If rIndex > 1 Then sText = sText & vbNewLine
For cIndex = 1 To Columns("BC").Column
If cIndex > 1 Then sText = sText & vbTab
sText = sText & Sheets("IMPORT-SHEET").Cells(rIndex, cIndex).Text
Next cIndex
Next rIndex
Set oStream = CreateObject("ADODB.Stream")
With oStream
.Type = 2
.Charset = "UTF-8"
.Open
.WriteText sText
.SaveToFile sTextPath, 2
.Close
End With
Set oStream = Nothing
End Sub