VBA / Macro - Cleaning Data

Asked

Viewed 73 times

0

Hello, I’m here cracking my head on how to modify a spreadsheet through a macro. Can anyone please help me?

I have a spreadsheet (Plan1) that has A1:AF720 formatting. I need to create a macro so that it is divided into several other spreadsheets (not tabs) with 100 lines each. I mean, I need to create 8 new spreadsheets!

Thank you!

1 answer

1

Follow the code you’ll 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.