Dividir excel en varias filas
Hace unos días pedí una macro para dividir un excel en filas, en concreto era de 400000 y quería en tramos de 10000, ahora necesito hacer de los 10000 tramos de 200 y no me esta funcionando porque me sale error 9 en tiempo de ejecución, subíndice fuera del intervalo.
Decir que yo solo modificaba los 10000 por 200, el compañero que me la creo me comento que modificara a1 y a2 según mis necesidades pero estoy un poco verde y no se a que se refería.
Sub separa()
Set datos = Sheets("hoja1").Range("a1").CurrentRegion
With datos
f = .Rows.Count
c = .Columns.Count
Set tabla = .Rows(2).Resize(f - 1, c)
filas = 10000
hojas = (f - 1) / filas
For i = 2 To hojas
On Error Resume Next
Sheets("hoja" & i).Select
If Err.Number > 0 Then
Sheets.Add After:=Sheets(Sheets.Count)
End If
On Error GoTo 0
If i = 2 Then Set tabla2 = tabla.Resize(f - 1, c)
If i > 2 Then Set tabla2 = tabla2.Rows(filas + 1).Resize(filas, c)
tabla2.Copy: Range("a2").PasteSpecial
tabla.Rows(0).Copy: Range("a1").PasteSpecial
Next i
End With
Set tabla = Nothing: Set tabla2 = Nothing
End Sub