Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I understand that the variable being used is an integer and needs to
be a Long, but I don't understand how to do it with the specific snippet I used... Any help would be appreciated. -J Denotes the line flagged in the debug window Public Function GetLast(Optional BookName As String, Optional SheetName _ As String, Optional Column As Boolean, Optional ColOrRow As String) As Integer Dim objFind As Range If BookName = "" Then BookName = ActiveWorkbook.Name End If If SheetName = "" Then SheetName = Workbooks(BookName).ActiveSheet.Name End If 'On Error Resume Next If Column = True Then If ColOrRow = "" Then Set objFind = Workbooks(BookName).Sheets(SheetName).UsedRange Else Set objFind = Workbooks(BookName).Sheets(SheetName).Range(ColOrR ow & _ ":" & ColOrRow) End If GetLast = objFind.Find(What:="*", searchdirection:=xlPrevious, _ searchOrder:=xlByColumns, LookIn:=xlValues).Column If Err.Number < 0 Then GetLast = 1 Exit Function End If Else If ColOrRow = "" Then Set objFind = Workbooks(BookName).Sheets(SheetName).UsedRange Else Set objFind = Workbooks(BookName).Sheets(SheetName).Range(ColOrR ow & _ ":" & ColOrRow) End If GetLast = objFind.Find(What:="*", searchdirection:=xlPrevious, _ searchOrder:=xlByRows, LookIn:=xlValues).Row If Err.Number < 0 Then GetLast = 1 Exit Function End If End If 'On Error GoTo 0 'Call the function with r=GetLast (for last row in sheet) 'or r=GetLast( , , , "A") for last row in col A 'or c=GetLast( , , True, "15") for last column in row 15. End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel 2003 print error number must be between 1 & 32767 | Excel Discussion (Misc queries) | |||
Overflow error, need help | Excel Programming | |||
Overflow error | Excel Programming | |||
Overflow Error | Excel Discussion (Misc queries) | |||
Help! Overflow Error 6 | Excel Programming |