LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with "Find Method"

I couldn't reproduce you problem of not finding 123 in cell A2 (make sure
A2 is not formatted as text and 123 is not stored as Text in A2).

I fixed the highlight problem:

Sub TestDan()
Dim MyRange As Range
Dim c As Range
Set MyRange = Worksheets("Sheet1").Range("A2:A10")
With MyRange
Set c = .Find(123, LookIn:=xlValues)
If Not c Is Nothing Then
ActiveSheet.Rows(c.Row).Interior.ColorIndex = 4
End If
End With
End Sub

--
Regards,
Tom Ogilvy

"Dan Thompson" wrote in message
...
Dan here I got some of the syntax wrong on the example code with my post

the
sub should look like this

Sub Test()
Dim MyRange As Range
Dim c As Range
Set MyRange = Worksheets("Sheet1").Range("A2:A10")
With MyRange
Set c = .Find(123, LookIn:=xlValues)
If Not c Is Nothing Then
.Rows(c.Row).Interior.ColorIndex = 4
End If
End With
End Sub

also...
If I put value 123 in cell A3 I need to also put (c.row - 1) or else it
highlights the cell right after the cell it found with value 123 not sure

why
I need the -1 ?

"Dan Thompson" wrote:

I am using the find method to search cells in a predefined Range I have

set up.
The problem is that the find method never includes the first row in the
predefined range for example...

Sub Test()
Dim MyRange as range
Dim c as range
Set MyRange = Worksheets("Sheet1").Range("A2:A10")
With MyRange
Set c = .Find(123, LookIn:=xlValues)
If c Not Nothing Then
.Rows(c.Row).Interior.colorindex = 4
end if
End With
End Sub

If the only cell in Sheet1 That has the value 123 in it is A2 then my

macro
does not find it ???

Is there a way to include the first cel in MyRange as part of the search

??

Dan.






 
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" a wildcard as a place marker and "replace" with original va Eric Excel Discussion (Misc queries) 1 January 27th 09 06:00 PM
"method 'execute' of object 'find' failed" [email protected][_2_] Excel Discussion (Misc queries) 0 August 31st 07 10:29 AM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM


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