title: Excel VBA: can't define range, get error object with block variable not set
body: <p>I'm trying to define a Range using VBA in Excel, </p>
  
  <pre><code>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
  </code></pre>
  
  <p>The first range <code>origem</code> is correctly defined without errors, but the second <code>destino</code> is throwing the error:</p>
  
  <pre><code>Object with block variable not set
  </code></pre>
  
  <p>On line:</p>
  
  <pre><code>destino = Sheets(separador).Range(Cells(10, 4), Cells(11, 5))
  </code></pre>
  
  <p>Can someone please explain me why, and how to fix this?</p>
  
  <p>Thanks in advance!</p>