Modificación de Macro Excel

Tengo esto mejoro pero necesito que cando no tenga datos no le pongo cero ya que no es necesario

Sub Diot()
Lines = Application.WorksheetFunction.CountA(Range("a3:a65536"))
Lines = Lines + 4
'catalogo de valores
For x = 5 To Lines
A = Left(Cells(x, 1), 2) & "|"
B = Left(Cells(x, 2), 2) & "|"
C = Cells(x, 3) & "|"
D = Round(Cells(x, 4), 0) & "|"
E = Cells(x, 5) & "|"
F = Right(Cells(x, 6), 2) & "|"
G = Cells(x, 7) & "|"
H = Round(Cells(x, 8), 0) & "|"
I = Round(Cells(x, 9), 0) & "|"
J = Round(Cells(x, 10), 0) & "|"
K = Round(Cells(x, 11), 0) & "|"
L = Round(Cells(x, 12), 0) & "|"
M = Round(Cells(x, 13), 0) & "|"
N = Round(Cells(x, 14), 0) & "|"
O = Round(Cells(x, 15), 0) & "|"
P = Round(Cells(x, 16), 0) & "|"
Q = Round(Cells(x, 17), 0) & "|"
R = Round(Cells(x, 18), 0) & "|"
S = Round(Cells(x, 19), 0) & "|"
T = Round(Cells(x, 20), 0) & "|"
U = Round(Cells(x, 21), 0) & "|"
V = Round(Cells(x, 22), 0) & "|"
'CONCATENA DATOS
Cells(x, 28) = A & B & C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V
Next x
'Guarda archivo
Range(Cells(5, 28), Cells(Lines, 28)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
direc = Application.GetSaveAsFilename(InitialFileName:="DEVIVA", _
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("F5").Select
End Sub

Añade tu respuesta

Haz clic para o