Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default [Range].Find Help

I'm using the following to search for values on each sh, if/when found
it copies values back to the activesheet. But if the value is in
multiple columns it sometimes uses that value instead. Since it's
only supposed to search in column 3 why would it even find that value
in the first place?

With sh
xEnd = .Cells(Rows.count, 3).End(xlUp).Row
Set xRng = .Range(.Cells(2, 3), .Cells(xEnd, 3))
End With

Set rng = xRng.Find( _
What:=i.Value, _
LookIn:=xlValues, _
MatchCase:=False)

Thanks,
-- Dan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default [Range].Find Help

I've never seen .find work that way.

Maybe it's time to double check to see what was found:

after the "set rng = xRng.find(...)" stuff:

if rng is nothing then
msgbox "not found"
else
msgbox rng.address & vblf & xrng.address
end if

===
Maybe it's picking up a partial match that you don't expect.

I would specify all the parms for that .Find() statement. If you don't, then
excel/VBA will use what was ever last used (either in code or by the user). And
that may not be what you want.

"Dan R." wrote:

I'm using the following to search for values on each sh, if/when found
it copies values back to the activesheet. But if the value is in
multiple columns it sometimes uses that value instead. Since it's
only supposed to search in column 3 why would it even find that value
in the first place?

With sh
xEnd = .Cells(Rows.count, 3).End(xlUp).Row
Set xRng = .Range(.Cells(2, 3), .Cells(xEnd, 3))
End With

Set rng = xRng.Find( _
What:=i.Value, _
LookIn:=xlValues, _
MatchCase:=False)

Thanks,
-- Dan


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default .Find Help

I'm sure the problem lies somewhere in the rest of my code but I
figured I'd ask. Thanks again Dave.

-- Dan

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
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
Find a range of values in a range of cells Jack Taylor Excel Worksheet Functions 20 November 25th 06 01:26 PM
Find the POSITION IN A RANGE of text in a string that matches value(s) in a range Cornell1992 Excel Programming 0 March 14th 06 07:19 PM
Find dates in a range; then sum values in that range by a criteria Anders Excel Discussion (Misc queries) 4 October 21st 05 03:41 PM
Find first cell in range and expand range -VBA Caméléon Excel Programming 3 December 4th 04 02:01 AM


All times are GMT +1. The time now is 11:22 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"