PDA

View Full Version : [SOLVED:] Bogus Range?



MWE
08-30-2005, 09:21 AM
I have a simple little proc that examines a Range and returns the "corners"



Sub xlRangeProps(xlTargetRange As Range, FirstRow, LastRow, FirstCol, LastCol)
On Error GoTo ErrorState
FirstRow = xlTargetRange.Row
MsgBox "1"
LastRow = FirstRow + xlTargetRange.Rows.Count - 1
MsgBox "2"
FirstCol = xlTargetRange.Column
MsgBox "3"
LastCol = FirstCol + xlTargetRange.Columns.Count - 1
Exit Sub
ErrorState:
FirstRow = -1
LastRow = -1
FirstCol = -1
LastCol = -1
End Sub


The MsgBox lines are just to track the progress of the proc. At one time, it ran fine. But it is now failing on the LastRow = line.

What is wrong?

Jacob Hilderbrand
08-30-2005, 09:26 AM
What is the error message?

ALe
08-30-2005, 09:36 AM
It works on my PC. What's the error number (if occurs)?

MWE
08-30-2005, 09:40 AM
well, that was the most interesting part; there was no error message. I removed the on error statement expecting the procedure to stop at the error and display an error message, but it did not.

Your response made me wonder what the error was, so I added a line in the error handler portion to display the error # and description. The problem was overflow. Once I knew that, the solution was pretty clear: the calling procedure was using Integers instead of Longs for the passed parameters.

Thanks