Re: Output Used Range To Text File
Thanks for the quick reply Dave
But I have 2 question:
1) will this code change or delete the contents in the active sheet?
As changing anything in the active sheet is a no no.
2) How do I want to make sure the contents that is in the column begin with "NOT" is not copy across to the text file?
I have started some code earier, is this any good?
- counter = 0
- rngMyFile.Value = output.txt
- strMyFile = ThisWorkbook.Path & "\" & rngMyFile.Value
- Set fs = CreateObject("Scripting.FileSystemObject").CreateTextFile(strMyFile, True)
- Set rngoutStart = Range("C1")
- ' need to find a way to loop the following that is not empty and not content "NOT" in the first row. and also the macro will stop as soon as it has 2 empty column next to eachother.
- Set rngMyText = GetDataCol(Range("C1").Offset(0, counter))
- For Each cell In rngMyText
- fs.writeline cell 'write line to text file
- Next cell
- Function GetDataArrayBelow(rngDataStart As Range, refRows As Integer) As Range
- ' To define the array from rngDataStart, column is read from rngDataStart.offset(refRows , 0)
- Dim rngDataEndLeftRef As Range, _
- rngDataEndLeftBot As Range
- ' Define Last cell
- Set rngDataEndLeftRef = rngDataStart.Offset(refRows, 0).End(xlToRight)
- Set rngDataEndLeftBot = rngDataEndLeftRef.End(xlDown)
- ' Define Data Range
- Set GetDataArrayBelow = Range(rngDataStart, rngDataEndLeftBot)
- End Function