marreco
Well-known Member
- Joined
- Jan 1, 2011
- Messages
- 609
- Office Version
- 2010
- Platform
- Windows
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?
I appreciate the help
Dear I have the following routine that exports to txt
Code:
[COLOR=#000000][FONT=Verdana]Sub Exportar() [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] Application.DisplayAlerts = False [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] template_file = ActiveWorkbook.FullName [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] fileSaveName = Application.GetSaveAsFilename( _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] InitialFileName:="C:\username" + _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] VBA.Strings.Format(Now, "mmddyyyy") + ".txt", _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] fileFilter:="Text Files (*.txt), *.txt") [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] If fileSaveName = False Then [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] Exit Sub [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] End If [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] 'cria uma cópia da pasta de trabalho atual da planilha atual [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] Dim newBook As Workbook [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] Dim plan As Worksheet [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] Set newBook = Workbooks.Add [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] ThisWorkbook.ActiveSheet.Copy Before:=newBook.Sheets(1) [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] 'exclui as demais planilhas [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] For Each plan In newBook.Sheets [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] If plan.Name <> ActiveSheet.Name Then [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] newBook.Worksheets(plan.Index).Delete [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] End If [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] Next [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] newBook.SaveAs Filename:= _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] fileSaveName, FileFormat:=xlTextWindows, _ [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] CreateBackup:=False [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] 'fecha a pasta de trabalho gerada [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] newBook.Close SaveChanges:=True [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] Set newBook = Nothing [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] MsgBox "O arquivo foi exportado com sucesso! ", vbInformation, "Exportar arquivos" [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana]End Sub[/FONT][/COLOR]
I appreciate the help