Export data to text file by template

alexugtx

New Member
Joined
Apr 29, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello,

I followed a tutorial for a POS application and I have to make it export the list of marked products in a text file according to a certain model.

I have a shape table:
Name QTY Tax Price

In this table, a product with its details is added on each line.

I need a piece of code that recognizes how lines many products there are and export data in a text file like this:
name tab-space qty tab-space price tab-space tax

So between the name, qty, price and tax you need a space equivalent to the "tab" button on keyboard.

If necessary, I can attach what I have worked so far, as well as the model in which it should be exported.
 
Hello,

do you mean you want to save-as a tab-delimited text file?

please upload the files to make it more clear
 
Upvote 0
Hello,

Because is simpler, I upload project and template on Drive: Project - Google Drive
The export must be done by pressing the "TIPARIRE" button, which is already assigned a macro.
It should be noted that for export I should add 0 0 A at the end of each row

Thank you!
 
Upvote 0
I come back with a clarification:
I have to export in text the columns from K10:M10 and O10 to the last written line
In the text file, the spacing between the contents of the columns must be done by "tab space"
 
Upvote 0
I solved.
It worked for me like this:

VBA Code:
    Dim FileName As String, LineText As String
    Dim Item, As Range, i, j
    Dim LastItemRow As Long
    FileName = "C:\file.txt" 'Linie generare fisier vanzari

LastItemRow = Range("E99").End(xlUp).Row
   
    Open FileName For Output As #1
    
    Set Item= Range("E10:H" & LastItemRow)
    
    For i = 1 To Item.Rows.Count
        For j = 1 To Item.Columns.Count
            LineText = IIf(j = 1, "", LineText) & Item.Cells(i, j) & vbTab 'Spatierea cu tab
            
        Next j
        Print #1, LineText
    Next i
    Close #1
 
Upvote 0
Solution

Forum statistics

Threads
1,226,812
Messages
6,193,123
Members
453,777
Latest member
Miceal Powell

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