<p>I'm trying to write a <a href="/questions/tagged/vba" class="post-tag" title="show questions tagged &#39;vba&#39;" rel="tag">vba</a> macro for a group tha</p>

<ul>
<li>has one workbook where they daily create new worksheets, and also have</li>
<li><em>Sheet 1</em>, <em>Sheet 2</em> and <em>Sheet 3</em> at the end of their long list of sheets. </li>
</ul>

<p>I need to create a external cell reference in a new column in a different workbook where this information is being summarized.</p>

<p>So I need to know how to get the <strong>last non-empty sheet</strong> so I can grab this data and place it appropriately in the summary.</p>

This function works through the sheets from right to left until it finds a non-blank sheet, and returns its name
```
```
Function GetLastNonEmptySheetName() As String
Dim i As Long
For i = Worksheets.Count To 1 Step -1
  If Sheets(i).UsedRange.Cells.Count > 1 Then
    GetLastNonEmptySheetName = Sheets(i).Name
    Exit Function
  End If
Next i
End Function
```
```