ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find (https://www.excelbanter.com/excel-programming/355546-find.html)

Judith

Find
 
How do i code a macro to find a value in a specific range of cells. The value
to locate will be typed by the user in a cell

Cells.Find(What:=B3, LookIn:=b5:b500).Activate ??????

Any suggestions please

thanks


Dave Peterson

Find
 
Dim FoundCell as Range
with activesheet
set foundcell = .range("b5:b500").find(what:=.range("b3").value)
if foundcell is nothing then
msgbox "not found"
else
foundcell.activate
end if
end with



judith wrote:

How do i code a macro to find a value in a specific range of cells. The value
to locate will be typed by the user in a cell

Cells.Find(What:=B3, LookIn:=b5:b500).Activate ??????

Any suggestions please

thanks


--

Dave Peterson

Chris Marlow

Find
 
Hi,

Try;

Range("b5:b500").Find(What:=Range("B3")).Activate

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"judith" wrote:

How do i code a macro to find a value in a specific range of cells. The value
to locate will be typed by the user in a cell

Cells.Find(What:=B3, LookIn:=b5:b500).Activate ??????

Any suggestions please

thanks


Risë

Find
 
Dave,

I tried this and it worked for me to an extent. It found the correct cell
but then I get
Run-time error '424':
Object required

here is what I have

Sub findreq()
Dim FoundCell As Range
With ActiveSheet
Set FoundCell = .Range("b4:b500").Find(What:=.Range("r1")).Activat e
If FoundCell Is Nothing Then
MsgBox "not found"
Else
FoundCell.Activate
End If
End With


End Sub

how do I get rid of the error?

"Dave Peterson" wrote:

Dim FoundCell as Range
with activesheet
set foundcell = .range("b5:b500").find(what:=.range("b3").value)
if foundcell is nothing then
msgbox "not found"
else
foundcell.activate
end if
end with



judith wrote:

How do i code a macro to find a value in a specific range of cells. The value
to locate will be typed by the user in a cell

Cells.Find(What:=B3, LookIn:=b5:b500).Activate ??????

Any suggestions please

thanks


--

Dave Peterson



All times are GMT +1. The time now is 03:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com