LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default .Find and With stmts

Hi All -
I'm building a function to do a find.
the "A" code below works. The "B" code does NOT, yet it's closer to MSo
example. I can't see the diff. Help?
"B" would be more efficient, yes ?
Thanks.

Function zFinds_ByRin1C(Ws As Worksheet, sLookFor As String, _
Col As Integer, FmRow As Long, ToRow As Long, _
bXlWhole As Boolean) As Long
Dim It As Range, WhoOrPrt
If bXlWhole = True Then WhoOrPrt = xlWhole Else WhoOrPrt = xlPart
If FmRow < 1 Then FmRow = 1
If ToRow < 1 Or ToRow MSoMaxRow Then ToRow = MSoMaxRow

With Ws ' A start
Set It = .Range(.Cells(FmRow, Col), .Cells(ToRow, Col)) _
.Find(sLookFor, LookIn:=xlValues, LookAt:=WhoOrPrt)
End With ' A end

' B start returns not found 0 value with same data in the worksheet.
'With Ws.Range(Cells(FmRow, Col), Cells(ToRow, Col))
' Set It = .Find(sLookFor, LookIn:=xlValues, LookAt:=WhoOrPrt)
'End With
' B end

If Not It Is Nothing Then zFinds_ByRin1C = It.Row
End Function
--
Neal Z
 
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
Multiple If Stmts Kgov Excel Discussion (Misc queries) 2 September 9th 09 07:23 PM
Nested 'If" stmts samoan Excel Discussion (Misc queries) 6 October 31st 08 01:37 PM
Creating macros with if stmts Lisa12 Excel Discussion (Misc queries) 3 July 15th 08 11:38 AM
Monthly bank stmts KathyT Excel Worksheet Functions 5 January 3rd 07 05:32 AM
simplify SUMIF stmts Monique Excel Programming 4 August 18th 05 09:56 PM


All times are GMT +1. The time now is 10:14 PM.

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"