I am working in Excel 2007. I am trying to define and select a range using a variable for the last row. The variable is defined (mouse over shows the right number), but I am getting an "application-defined or object-defined" error. I am new to VBA in Excel and doing anything with ranges and cells. The code is:
Dim LastRow As Long
LastRow = FindLastRow()
Sheets(ActiveSheet).Range(Cells(11, 1), Cells(13,LastRow)).Select
The FindLastRow() function is(which I found here):
Function FindLastRow()
r = ActiveSheet.UsedRange.Rows.Count
c = ActiveSheet.UsedRange.Columns.Count
FindLastRow = r
End Function
John Green
Dim LastRow As Long
LastRow = FindLastRow()
Sheets(ActiveSheet).Range(Cells(11, 1), Cells(13,LastRow)).Select
The FindLastRow() function is(which I found here):
Function FindLastRow()
r = ActiveSheet.UsedRange.Rows.Count
c = ActiveSheet.UsedRange.Columns.Count
FindLastRow = r
End Function
John Green