Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Error 6: Overflow 32767 Rows

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Error 6: Overflow 32767 Rows

Juan,

Replace "Integer" with "Long"...


Public Function GetLast(Optional BookName As String, Optional
SheetName _
As String, Optional Column As Boolean, Optional ColOrRow As String) As
Long



--
Hope that helps.

Vergel Adriano


"Juan Schwartz" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Error 6: Overflow 32767 Rows

Can't believe I overlooked that!

Thank you very much Vergel. The error is gone.

-Juan

On Jul 23, 11:50 am, Vergel Adriano
wrote:
Juan,

Replace "Integer" with "Long"...

Public Function GetLast(Optional BookName As String, Optional
SheetName _
As String, Optional Column As Boolean, Optional ColOrRow As String) As
Long

--
Hope that helps.

Vergel Adriano


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2003 print error number must be between 1 & 32767 robertsnissen Excel Discussion (Misc queries) 1 September 3rd 07 01:26 PM
Overflow error, need help mkerstei[_15_] Excel Programming 3 July 14th 06 03:10 AM
Overflow error Grd Excel Programming 1 January 21st 06 08:13 AM
Overflow Error DG Excel Discussion (Misc queries) 3 April 15th 05 05:45 PM
Help! Overflow Error 6 Gauthier Excel Programming 6 September 24th 04 12:57 PM


All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"