Saving as Tab delimited... missing fields??

kidcrust

New Member
Joined
Jul 18, 2007
Messages
2
The weirdest thing seems to be happening in my worksheet I have a field that is the last of my header row and it is unpopulated most of the time with the exception of my header. I am attempting to save this worksheet as tab delimited text to import the data in an application that was written. However when I save as txt the tab for the last field disappears after 16 records everytime?? I need to have all thirteen fields recognized for my import process to work and sometimes the 13th maybe populated?? anyone have any ideas as to why excel would choose not to recognize this blank column after 16 records everytime and what I could do to fix this?
 
Not weird at all "It Is A Feature Not A Bug" (at least that'ts what we expect Microsoft to tell us) :-D :-D :-D

It's all about Excel trying to do our thinking for us. So we have to get down to "grass roots basics" and go from there. Here is something I prepared earlier.
Code:
'===========================================================================
'- MACRO TO CONVERT WORKSHEET TO PIPE OR TAB (or other) DELIMITED TEXT FILE
'- WS HAS TO BE SET UP AS A SIMPLE TABLE. RUN MACRO FROM THE SHEET
'- Brian Baulsom April 2002
'===========================================================================
'-
Sub EXPORT_SHEET_TO_TEXT()
    Dim FileName As String      ' .txt FILENAME AS WORKSHEET
    Dim MyRow As Long
    Dim MyCol As Integer
    Dim MyReturn As String
    Dim ws As Worksheet
    Dim LastRow As Long
    Dim ColumnCount As Integer
    Dim MyDelimiter As String
    '---------------------------------------------------------------------
    Application.Calculation = xlCalculationManual
    '- set the delimiter required
    'MyDelimiter = "|"       ' pipe
    MyDelimiter = Chr(9)    ' tab
    '---------------------------------------------------------------------
    Set ws = ActiveSheet
    MyReturn = Chr(13)
    FileName = ws.Name & ".txt"
    '----------------------------------------------------------------------
    '- get number of rows (to allow for blank cells)
    LastRow = ws.Cells.Find(What:="*", SearchDirection:=xlPrevious, _
        SearchOrder:=xlByRows).Row
    '----------------------------------------------------------------------
    '- get number of columns
    ColumnCount = ws.Cells.Find(What:="*", SearchDirection:=xlPrevious, _
        SearchOrder:=xlByColumns).Column
    '----------------------------------------------------------------------
    '- EXPORT TO FILE
    Open FileName For Append As #1
    '- loop through rows & columns
    For MyRow = 1 To LastRow
       For MyCol = 1 To ColumnCount
           Print #1, ws.Cells(MyRow, MyCol).Value;
           If MyCol < ColumnCount Then Print #1, MyDelimiter;   ' Column
       Next
       Print #1, MyReturn;   ' end of line Return
    Next
    '----------------------------------------------------------------------
    Close #1
    MsgBox ("Done")
    Application.Calculation = xlCalculationAutomatic
End Sub
'=========== END OF PROCEDURE =============================================
 
Upvote 0

Forum statistics

Threads
1,226,799
Messages
6,193,069
Members
453,773
Latest member
bclever07

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top