I'm trying to define a Range using VBA in Excel,
Sub convertePerc()
Dim separador As String
Dim linhaInicial, linhaFinal, colunaInicial, colunaFinal, numAnos As Integer
Dim origem, destino As Range
separador = "DRES(G)"
colunaFinal = Sheets(separador).Cells(6, 5).End(xlToRight).Column
linhaFinal = 40
numAnos = 10
origem = Sheets(separador).Range(Cells(10, 4), Cells(linhaFinal, colunaFinal))
colunaInicial = CInt(4 + numAnos + 1)
colunaFinal = CInt(numAnos + colunaFinal + 1)
destino = Sheets(separador).Range(Cells(10, 4), Cells(11, 5))
End Sub
The first range origem
is correctly defined without errors, but the second destino
is throwing the error:
Object with block variable not set
On line:
destino = Sheets(separador).Range(Cells(10, 4), Cells(11, 5))
Can someone please explain me why, and how to fix this?
Thanks in advance!