VBA to fill empty cell

Asked

Viewed 924 times

-1

good morning,

I have a spreadsheet in excel that I would like when I impute a date and press the macro button to paste into the next empty cell in column A, 74 times. And also copy two columns (B:C) with 74 values each and also play in the next empty, I will send an image to summarize, I do not know anything macro or VBA, so I would really need help.

The big red circle would be the other values that he would have to copy and paste, these do not change so it can be let’s suppose B2:C75 to play in the next empty also that would be in columns B and C.

inserir a descrição da imagem aqui

1 answer

1

Good afternoon to you, Bruno! Follow the code that will probably start to help you, I confess that it was not very clear what you asked but already served to start the lines below. I hope it helps that anything only returns in this topic. Assign the macro process() one-button.

Option Explicit

Const total_de_linhas_preenchidas As Long = 74

Sub s_processo()
    Application.ScreenUpdating = False
    f_processo
    turno_horario
End Sub

Private Function f_processo()
    'executa somente na coluna A e em uma célula vazia.
    Dim celula_com_data As String
    Dim linha As Long
    Dim it As Long
    celula_com_data = "I1"
    If ActiveCell.Column = 1 And ActiveCell.Value = Empty Then
        linha = ActiveCell.Row
        For it = linha To (total_de_linhas_preenchidas + linha)
            Range("A" & it).Value = Range(celula_com_data).Value
        Next it
    End If
    celula_com_data = ""
    linha = 0
    it = 0
End Function

Private Function turno_horario()
    Dim faixa As String
    Dim celula_com_data As String
    Dim linha As Long
    Dim it As Long
    celula_com_data = "I1"
    faixa = "B2:C9"
    If ActiveCell.Column = 1 Then
        linha = ActiveCell.Row
        For it = linha To (total_de_linhas_preenchidas + linha) Step 10
            Range(faixa).Copy Destination:=Range("B" & it)
        Next it
    End If
    celula_com_data = ""
    linha = 0
    it = 0
    faixa = ""
End Function

Browser other questions tagged

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