title: Is there a way to use Cells.Address as part of a range ("A1:Cells.Address") for an input to a function?
body: <p>I cannot seem to make this work. I have a line that finds the address of the last cell in the table of data.</p>
  <pre><code>r = Range(Range(&quot;A2&quot;), Range(&quot;A2&quot;).End(xlDown)).Rows.Count 
  Range(&quot;A1&quot;, Cells(r + 1, 5).Address(RowAbsolute:=False, ColumnAbsolute:=False)).Select
  </code></pre>
  <p>Then using this information, later on I need to input the range A1:E35 where the E35 corresponds to:</p>
  <pre><code>Cells(r + 1, 5).Address(RowAbsolute:=False, ColumnAbsolute:=False))
  </code></pre>
  <p>Using Ron de Bruin's CopyRangeToJPG function,</p>
  <pre><code>Function CopyRangeToJPG(NameWorksheet As String, RangeAddress As String) As String
  'Ron de Bruin, 25-10-2019
  Dim PictureRange As Range
  
  With ActiveWorkbook
      On Error Resume Next
      .Worksheets(NameWorksheet).Activate
      Set PictureRange = .Worksheets(NameWorksheet).Range(RangeAddress)
      
      If PictureRange Is Nothing Then
          MsgBox &quot;Sorry this is not a correct range&quot;
          On Error GoTo 0
          Exit Function
      End If
  </code></pre>
  <p>It doesn't get past the validation check. What should the RangeAddress field be? I need this to be dynamic since it won't always be A1:E35 in this case. I would have thought that the following might have worked but I guess this isn't the right way.</p>
  <pre><code>CopyRangeToJPG(&quot;Sheet2&quot;, &quot;A1:(Cells(r + 1, 5).Address(RowAbsolute:=False, ColumnAbsolute:=False))&quot;).
  </code></pre>
  <p>Thanks</p>