Excel Macro TXT cada 100 Filas

21/04/2016 - 19:51 por rafael.2ch | Informe spam
Buenas tardes necesito crear una macro para hacer tantos txt de una columna en particular cada 100 filas

Ejemplo de la columna "B"

crear varios txt
txt1 : de B1:B100
txt2 : de B101:B200
txt3 : de B201:B300
.
.
.


y así sucesivamente hasta que ya no encuentre data en la columna B


:(

Alguna sugerencia.


Saludos,
 

Leer las respuestas

#1 rafael.2ch
21/04/2016 - 20:25 | Informe spam
Y_Y yo mismo me respondo,

Quizás a alguien mas le sirva alguna vez.

Saludos

Sub MacroPeru()
'
'by Cacho
'
Dim mPath$, iniCell$, i&, LR&, Vec, j%, iniTime!, R%

iniCell = "$B$2"

iniTime = Timer
mPath = ThisWorkbook.Path & "\Txt\"

With CreateObject("Scripting.FileSystemObject")
On Error Resume Next: .GetFolder(mPath).Delete True: On Error GoTo 0
.GetFolder(ThisWorkbook.Path).subFolders.Add "Txt"
End With

LR = Cells(Rows.Count, Range(iniCell).Column).End(xlUp).Row

For i = Range(iniCell).Row To LR Step 100
Vec = Cells(i, Range(iniCell).Column).Resize(100)
R = 1 + R
Open mPath & Format(R, "0000") & ".txt" For Output As #1
For j = 1 To 100
If Vec(j, 1) = "" Then Exit For
Print #1, Vec(j, 1)
Next
Close
Next
MsgBox "Proceso terminado en: " & Format(Timer - iniTime, "0.00 seg")
End Sub

Preguntas similares