Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem with exported text
The code below works all the way up to the point where it exports the data to
a text file. When I look within the text file I find that it includes bland rows as well as the rows with the data. I did add a formula to column 1 so that when they enter a specific value it always makes it a 1. Otherwise it leaves the cell blank. =IF(N8<"",1,"") is the formula in column A starting on row 8. Text file has the following as the results... which goes on for one hundred rows which is how far down I copied the above formula. 1;;test;;;test;;;;;;;;s;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;; Sub Button1_Click() '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''' ' This exports the data to a semicolon seperated text file. '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''' Dim fileName As String 'Dim inputRow As String Dim FNum As Integer Dim RowNdx As Long Dim ColNdx As Integer Dim EndRow As Long Dim CellValue As String Dim currPath As String Dim slnum As String slnum = UCase(Range("C8:C8").Value) Application.ScreenUpdating = False On Error GoTo EndMacro: FNum = FreeFile currPath = ActiveWorkbook.Path fileName = currPath & "\" & slnum & "_Appendix1data.TXT" With ActiveSheet.UsedRange EndRow = .Cells(.Cells.Count).Row End With Open fileName For Output Access Write As #FNum If EndRow = 8 Then For RowNdx = 8 To EndRow 'inputRow = "" For ColNdx = 1 To 24 If Cells(RowNdx, ColNdx).Value = "" Then CellValue = "" Else CellValue = Cells(RowNdx, ColNdx).Text End If ' inputRow = inputRow & CellValue & ";" Next ColNdx 'inputRow = Left(inputRow, Len(inputRow) - 1) Print #FNum, ' inputRow Next RowNdx Else GoTo EndMacro: End If EndMacro: On Error GoTo 0 Application.ScreenUpdating = True Close #FNum MsgBox ("Formated Data is stored in " & fileName) End Sub -- Matt |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data from exported file read as text, when edited becomes a # (pic | Excel Discussion (Misc queries) | |||
Exported from Access - text has a character before it | Excel Discussion (Misc queries) | |||
Need quotes around exported tab delimited text | Excel Discussion (Misc queries) | |||
Dates exported as text | Excel Programming | |||
why are there quotes in my exported text file? | Excel Discussion (Misc queries) |