Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem with txt
Nuno,
Better to control exactly what gets written to the file using a macro. See an example below. HTH, Bernie MS Excel MVP Sub ExportToTXT() Dim FName As String Dim WholeLine As String Dim FNum As Integer Dim RowNdx As Long Dim ColNdx As Integer Dim StartRow As Long Dim EndRow As Long Dim StartCol As Integer Dim EndCol As Integer FName = "C:\Excel\ExportText.txt" Application.ScreenUpdating = False On Error GoTo EndMacro: FNum = FreeFile With Range("A2").CurrentRegion StartRow = .Cells(1).Row StartCol = .Cells(1).Column EndRow = .Cells(.Cells.Count).Row EndCol = .Cells(.Cells.Count).Column End With Open FName For Output Access Write As #FNum For RowNdx = StartRow To EndRow WholeLine = "" For ColNdx = StartCol To EndCol WholeLine = WholeLine & " """ & _ Cells(RowNdx, ColNdx).Text & """ " Next ColNdx Print #FNum, WholeLine Next RowNdx EndMacro: On Error GoTo 0 Application.ScreenUpdating = True Close #FNum End Sub "Nuno" wrote in message ... Hi everyone! I was wondering if you cound help with a problem I'm having with Excel. I have a list of codes that I want Excel to save in txt format with the "". I'll explain: I have thousands of codes in a numerical format (e.g. 3173471; 3174742, etc.) but I need to save a txt file that puts "" around the value, i.e., "3173471", "3174742", etc. I've tried to use the concatenate function, replace and even tried to program a macro (I'm not that proficient in macros, so something could be wrong...) but nothing worked. The best i could was using the replace function and, in fact, in Excel it looked as if everything was correct, i.e., i saw "3174742", . However, when I saved it to txt I got this weird result: """3174742""". I could try to make the replacement in word or notepad, but given the huge amount of files I'm using this would be to cumbersome. Does anyone has an idea how I could get around this? Cheers, Nuno |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) | |||
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? | Excel Programming |