VBA / Macro - Cleaning Data [closed]

0

Hello, I'm here here breaking my head on how to modify a spreadsheet through a macro. Can someone please help me?

I have a worksheet (Plan1) that have the formatting A1: AF720. I need to create a macro so that it is split into several other sheets (not tabs) with 100 rows each. That is, I need to create 8 new spreadsheets!

Thank you!

    
asked by anonymous 24.04.2018 / 14:03

1 answer

1

Here is the code you need:

Sub dividir_planilha()
    Dim linha_origem As Integer, coluna_origem As Integer, plan As Integer
    Dim linha_destino As Integer, coluna_destino As Integer

    linha_origem = 1
    coluna_origem = 1
    plan = 0

    Do
        Dim excel As New excel.Application
        excel.Workbooks.Add
        excel.Visible = True
        linha_destino = 1
        Do
        coluna_destino = 1
            For coluna_origem = 1 To 32
                excel.Cells(linha_destino, coluna_destino).Value = Cells(linha_origem, coluna_origem).Value
                coluna_destino = coluna_destino + 1
            Next coluna_origem
            linha_destino = linha_destino + 1
            linha_origem = linha_origem + 1
        Loop Until linha_destino = 101
        plan = plan + 1
    Loop Until plan = 8
End Sub
    
25.04.2018 / 18:55