tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,834
- Office Version
- 365
- 2019
- Platform
- Windows
I have this function which calculates the last row in a column of a particular worksheet:
so if I put a value in cell E10 and then write in the immediate window:
I get 10 returned, which is correct.
Assume now I put a value in cell E1048676, ie the last row in column E.
This still returns 10:
it's as if it ignores the "real" last row and returns the next one, which is the row of the value in cell E10.
What is wrong with function?
Thanks
Rich (BB code):
Public Function LRowInCol(ByRef wks As Worksheet, ByRef Col As Integer) As Long
With wks
LRowInCol = .Cells(.Rows.Count, Col).End(xlUp).Row
End With
End Function
so if I put a value in cell E10 and then write in the immediate window:
Rich (BB code):
? LRowInCol(Sheet1, 5)
I get 10 returned, which is correct.
Assume now I put a value in cell E1048676, ie the last row in column E.
This still returns 10:
Rich (BB code):
Rich (BB code):
Rich (BB code):
? LRowInCol(Sheet1, 5)
it's as if it ignores the "real" last row and returns the next one, which is the row of the value in cell E10.
What is wrong with function?
Thanks