Good morning @Mario Felicio
Follow the code of the Macro:
Sub CopyPaste()
Dim ws As Worksheet
Dim qtde As Integer
Dim linFrom As Integer
Dim linTo As Integer
Dim colFrom As String
Dim colTo As String
'inicializando minhas variáveis
colFrom = "M"
colTo = "N"
linFrom = 1
linTo = 1
'Definindo qual a planilha
Set ws = Worksheets("Plan1")
'Identificando qual a última linha
qtde = ws.Cells(Rows.Count, colFrom).End(xlUp).Offset(1, 0).Row
'fazendo um loop até o meu último registro da coluna de Origem
While linFrom <= qtde
'verificando se a minha célula de origem possui valor
If ws.Cells(linFrom, colFrom) <> "" Then
'se houver valor, copio para a minha célula de destino
ws.Cells(linTo, colTo) = ws.Cells(linFrom, colFrom)
'passando para minha próxima linnha de destino
linTo = linTo + 1
End If
'passando para minha próxima linha de origem
linFrom = linFrom + 1
Wend
End Sub
Note that I have put the columns M and N in variables to make it easier if you need to change the source and destination columns.
Just copy the above code, enter the developer menu / Visual Basic, paste this code and save. Then just click on Macros and select it.
Remembering that your spreadsheet will have to be saved with Macros support.
I hope I’ve helped!
friend Thomas. This is what I wanted, I changed "lymphrom=1";"Linto=1", to separate the months, I also changed "while lymphrom<=Qtde", to the last line of each month. ie I made 12 modules, each with these lines changed. is working.
– Mario Felicio
Wonder...!!!
– Thomas Lima