I have the following function in an Autocad module.
The Object f is an Excel Workbook.
In the Autocad VBA immediate window I can create a Excel application and open a workbook.
Then
? LastRow(myxlbook)
gives a "Subscript out of range" error.
What subscript?
While trying to figure this out, I did:
In the immediate window:
? LastRow(myxlbook)
Sheet1
0
So somehow this is returning two answers, although I don't understand where the 0 is coming from or what it is.
Code:
Public Function LastRow(ByVal f As Object) As Long
LastRow = f.activesheet.cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
End Function
The Object f is an Excel Workbook.
In the Autocad VBA immediate window I can create a Excel application and open a workbook.
Then
? LastRow(myxlbook)
gives a "Subscript out of range" error.
What subscript?
While trying to figure this out, I did:
Code:
Public Function LastRow(ByVal f As Object) As Long
Debug.Print f.activesheet.Name
'LastRow = f.activesheet.cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
End Function
In the immediate window:
? LastRow(myxlbook)
Sheet1
0
So somehow this is returning two answers, although I don't understand where the 0 is coming from or what it is.