![]() |
Need to export to text results not formula
I need to export only the results to a text file not the formulas.
I have vlookups that when I export the formula goes to the text file but instead I need only the results of the query. I am usnig the following macro: Public Sub SaveAsTXT() fileSaveName = Application.GetSaveAsFilename( _ FileFilter:="Text Files (*.txt), *.txt") If fileSaveName < False Then MsgBox "Save as " & fileSaveName End If End Sub Thank you, Muaitai |
Need to export to text results not formula
I think maybe the easiest way to do this is to kind of start over. The code
you have will save the entire workbook, just renamed with a .txt extension instead of a .xls extension. Try using some code similar to this, lets assume you want to save the information on rows 1 through 50 on a sheet in .txt format (and there are several to choose from), this is for MS-DOS text, no delimiters: Sub SaveDataAsText() Rows("1:50").Select ActiveWorkbook.SaveAs Filename:="G:\ExcelHelp_21June2006.txt", _ FileFormat:=xlTextMSDOS End Sub Now that has the filename hard coded, you could use other code to get a filename from the user or yourself. If we change things a little, it all can be done in a single macro Sub SaveDataAsText() Dim fName As Variant Rows("1:50").Select fName = Application.GetSaveAsFilename( _ fileFilter:="MS-DOS text files (*.txt), *.txt") If fName = "" Then ' user [Cancel]ed Exit Sub End If On Error Resume Next ActiveWorkbook.SaveAs Filename:=fName, _ FileFormat:=xlTextMSDOS If Err < 0 Then 'user probably cancelled at this point 'as when notified of existing file of same name 'you can either test for errors 'or simply ignore them Err.Clear End If On Error GoTo 0 ' clear error trapping End Sub "Muaitai" wrote: I need to export only the results to a text file not the formulas. I have vlookups that when I export the formula goes to the text file but instead I need only the results of the query. I am usnig the following macro: Public Sub SaveAsTXT() fileSaveName = Application.GetSaveAsFilename( _ FileFilter:="Text Files (*.txt), *.txt") If fileSaveName < False Then MsgBox "Save as " & fileSaveName End If End Sub Thank you, Muaitai |
Need to export to text results not formula
You have a response at your first post.
Muaitai wrote: I need to export only the results to a text file not the formulas. I have vlookups that when I export the formula goes to the text file but instead I need only the results of the query. I am usnig the following macro: Public Sub SaveAsTXT() fileSaveName = Application.GetSaveAsFilename( _ FileFilter:="Text Files (*.txt), *.txt") If fileSaveName < False Then MsgBox "Save as " & fileSaveName End If End Sub Thank you, Muaitai -- Dave Peterson |
All times are GMT +1. The time now is 03:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com