I found two typo errors in the code. I saw a number of problems in the
original code and fixed them when I posted the code. this should give
the results you are looking for.
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"
Open fileName For Output Access Write As #FNum
With ActiveSheet
'get last row of data
EndRow = 0
For ColNdx = 1 To 24
LastRow = .Cells(Rows.Count, ColNdx).End(xlUp).Row
If LastRow EndRow Then
EndRow = LastRow
End If
Next ColNdx
If EndRow = 8 Then
For RowNdx = 8 To EndRow
LastCol = .Cells(RowNdx, Columns.Count).End(xlToLeft).Column
If LastCol < 1 Or .Range("A" & RowNdx) < "" Then
For ColNdx = 1 To LastCol
CellValue = Cells(RowNdx, ColNdx).Text
If ColNdx = 1 Then
OutputLine = CellValue
Else
OutputLine = OutputLine & ";" & CellValue
End If
Next ColNdx
Print #FNum, OutputLine
End If
Next RowNdx
End If
End With
EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True
Close #FNum
MsgBox ("Formated Data is stored in " & fileName)
End Sub
--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=189337
http://www.thecodecage.com/forumz/chat.php