Hi.
Dear I have the following routine that exports to txt
The doubt is as follows, in order that the code is the same txt all exports to spreadsheet rows or 65536 rows! How can I adjust to the routine that exports only rows filled?Code:Sub Exportar() Application.DisplayAlerts = False template_file = ActiveWorkbook.FullName fileSaveName = Application.GetSaveAsFilename( _ InitialFileName:="C:\username" + _ VBA.Strings.Format(Now, "mmddyyyy") + ".txt", _ fileFilter:="Text Files (*.txt), *.txt") If fileSaveName = False Then Exit Sub End If 'cria uma cópia da pasta de trabalho atual da planilha atual Dim newBook As Workbook Dim plan As Worksheet Set newBook = Workbooks.Add ThisWorkbook.ActiveSheet.Copy Before:=newBook.Sheets(1) 'exclui as demais planilhas For Each plan In newBook.Sheets If plan.Name <> ActiveSheet.Name Then newBook.Worksheets(plan.Index).Delete End If Next newBook.SaveAs Filename:= _ fileSaveName, FileFormat:=xlTextWindows, _ CreateBackup:=False 'fecha a pasta de trabalho gerada newBook.Close SaveChanges:=True Set newBook = Nothing MsgBox "O arquivo foi exportado com sucesso! ", vbInformation, "Exportar arquivos" End Sub
Cross-Post
Xls export to txt
I appreciate the help




Reply With Quote

Bookmarks