Hi,
I would like to export an sheet in excel into a text file.
This is my code:
Problem: I need changes in the code so thatCode:Sub text()
Dim myFile As String, rng As Range, cellValue As Variant, i As Integer, j As Integer
myFile = "D:\test.txt"
Set rng = Selection
Open myFile For Output As #1
For i = 1 To rng.Rows.Count
For j = 3 To rng.Columns.Count
cellValue = rng.Cells(i, j).Value
If j = rng.Columns.Count Then
Write #1, cellValue
Else
Write #1, cellValue,
End If
Next j
Next i
Close #1
End Sub
1. no selection is nessesery - just take the open sheet, take all the rows and lines with a content ( if no content just go to the next )
2. start in line 1 row 3
3. never export rows 5 to 6 no matter if empty or not
4. write all in a textfile looking like in excel
THX a lot!