I am very new to this programming, and I have taken a pre-written script and am having troubles trying to figure out methods on how I can make this script bend to my needs.
I need for this script to automatically set the length value, but this value is differen't for each column.
I have about 30 columns and each one needs to be a different length. Though it is standard for each time I run the macro so it can be a set variable.
BTW, this script exports all the active colums and rows into a text-delimited text file.
Code:
Sub Export()
Dim Length
Dim z%, s%
Dim TMP$
Length = InputBox("FieldLength:")
If Length = "" Then Length = 20
Open "test.txt" For Output As #1
For z = 1 To ActiveSheet.UsedRange.Rows.Count
For s = 1 To ActiveSheet.UsedRange.Columns.Count
TMP = TMP & CStr(Cells(z, s).Text) & String(Length - Len(Cells(z, s).Text), " ")
Next s
Print #1, TMP
TMP = ""
Next z
Close 1
MsgBox "The data names are stored under the following address:" & Chr(13) & _
CurDir() & "\test.txt"
End Sub