Convertir a txt
¿Ójala me puedas ayudar tengo una macro que convierte los datos que hay en la hoja de excel a txt sin embargo solo lo hace con las primeras cinco filas algo esta fallando y no se es me podrías ayudar?
De antemano agradezco la ayuda que me puedas brindar
Sub carga()
'HASTA DONDE
Lines = Application.WorksheetFunction.CountA(Range("a6:a65536"))
Lines = Lines + 4
'catalogo de valores
For x = 6 To Lines
a = Left(Cells(x, 1), 2) & "|"
b = Left(Cells(x, 2), 2) & "|"
c = Cells(x, 3) & "|"
d = Cells(x, 4) & "|"
E = Cells(x, 5) & "|"
F = Right(Cells(x, 6), 2) & "|"
G = Cells(x, 7) & "|"
H = Cells(x, 8) & "|"
I = Cells(x, 9) & "|"
J = Cells(x, 10) & "|"
K = Cells(x, 11) & "|"
L = Cells(x, 12) & "|"
M = Cells(x, 13) & "|"
N = Cells(x, 14) & "|"
O = Cells(x, 15) & "|"
P = Cells(x, 16) & "|"
Q = Cells(x, 17) & "|"
R = Cells(x, 18) & "|"
S = Cells(x, 19) & "|"
T = Cells(x, 20) & "|"
'une datos EMPIEZA EN LA CELDA DE LA z
Cells(x, 38) = a & b & c & d & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T
Next x
'graba en disco
Range(Cells(6, 38), Cells(Lines, 38)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
direc = Application.GetSaveAsFilename(InitialFileName:="infoiva", _
fileFilter:="archivos de texto (*.txt), *.txt", Title:="Guardar archivo Carga-Batch Como:")
ActiveWorkbook.SaveAs Filename:= _
direc, FileFormat:= _
xlTextPrinter, CreateBackup:=False
ActiveWindow.Close savechanges:=False
Selection.ClearContents
Range("A6").Select
End Sub
De antemano agradezco la ayuda que me puedas brindar
1 respuesta
Respuesta de Juan Carlos González Chavarría
1
