N
Neal Zimm
Hi all,
The function below works fine, and it seems to run pretty quickly. I also
use it to find rows with data that are NOT at the very end of a worksheet.
#1. As I become more familiar with with the Find method I wonder how much
more efficient it would be versus what I've written. Your opinions? (I'm just
setting up a good timing mechanisim to test it, as I use the function a fair
amount.)
#2. Also, I've not yet tested whether or not the special cells type
xlcelltypeblanks means null or no "real" value. I have the requirement of
ignoring cells containing only spaces.
p.s. I use the SaveASU statements so I don't have to really keep track of
when I turn screen updating on or off.
Function Row_WsLastGetF(IWs As Worksheet, IHighRow As Long, _
IFromCol As Integer, IToCol As Integer) As Long
' Return the largest row# found with a value, starting from the
' IHighRow to row 1. A cell with only spaces is considered as
' having no value.
' Columns tested run from IFromCol to and including IToCol.
' 0 is returned for nothing found.
Dim SaveASU As Boolean, Col As Integer
SaveASU = Application.ScreenUpdating
Application.ScreenUpdating = False
With IWs
For Row_WsLastGetF = IHighRow To 1 Step -1
For Col = IFromCol To IToCol
If Trim(.Cells(Row_WsLastGetF, Col).Value) <> "" Then GoTo Ending
Next Col
Next Row_WsLastGetF
Row_WsLastGetF = 0
Ending:
End With
Application.ScreenUpdating = SaveASU
End Function
The function below works fine, and it seems to run pretty quickly. I also
use it to find rows with data that are NOT at the very end of a worksheet.
#1. As I become more familiar with with the Find method I wonder how much
more efficient it would be versus what I've written. Your opinions? (I'm just
setting up a good timing mechanisim to test it, as I use the function a fair
amount.)
#2. Also, I've not yet tested whether or not the special cells type
xlcelltypeblanks means null or no "real" value. I have the requirement of
ignoring cells containing only spaces.
p.s. I use the SaveASU statements so I don't have to really keep track of
when I turn screen updating on or off.
Function Row_WsLastGetF(IWs As Worksheet, IHighRow As Long, _
IFromCol As Integer, IToCol As Integer) As Long
' Return the largest row# found with a value, starting from the
' IHighRow to row 1. A cell with only spaces is considered as
' having no value.
' Columns tested run from IFromCol to and including IToCol.
' 0 is returned for nothing found.
Dim SaveASU As Boolean, Col As Integer
SaveASU = Application.ScreenUpdating
Application.ScreenUpdating = False
With IWs
For Row_WsLastGetF = IHighRow To 1 Step -1
For Col = IFromCol To IToCol
If Trim(.Cells(Row_WsLastGetF, Col).Value) <> "" Then GoTo Ending
Next Col
Next Row_WsLastGetF
Row_WsLastGetF = 0
Ending:
End With
Application.ScreenUpdating = SaveASU
End Function