Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Nigel
 
Posts: n/a
Default Find cell contents in range

Hi,
i am really struggling to create a macro to carry out the following.
( i am quite new to this and presently using a book but things are explained
fully!)

lets say cell K12 = 2245
i have a range of A2:A50 containing a list between 2220 & 2270

i need my macro to look at the value of K12. Find that value in range, and
make the cell with that value active
so in my list between 2220 & 2270 is an activecell where the value is 2245

i hope this can be done and hope that someone can help me.

Regards,

Nigel

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

With Worksheets(1).Range("A2:A50") Set cell = .Find(Range("K12").Value,
LookIn:=xlValues) If Not cell Is Nothing Then cell.Activate End
IfEnd With-- HTH
Bob Phillips

"Nigel" wrote in message
...
Hi,
i am really struggling to create a macro to carry out the following.
( i am quite new to this and presently using a book but things are

explained
fully!)

lets say cell K12 = 2245
i have a range of A2:A50 containing a list between 2220 & 2270

i need my macro to look at the value of K12. Find that value in range, and
make the cell with that value active
so in my list between 2220 & 2270 is an activecell where the value is 2245

i hope this can be done and hope that someone can help me.

Regards,

Nigel



  #4   Report Post  
WillR
 
Posts: n/a
Default

Something like this would do it...

Sub findit()
Dim rngFound As Range
Dim rngFind As Range
Dim rngStart As Range
Dim strFind As String

strFind = Range("K12").Value
'set the range to search
Set rngFind = Range("A2:A50")
'set where to start the search
Set rngStart = rngFind.Cells(1)
'try & find it
Set rngFound = rngFind.Find(What:=strFind, After:=rngStart,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False)
'found it
If Not rngFound Is Nothing Then
MsgBox "Value Found at: " & rngFound.Address
rngFound.Activate
Else
'didn't find it
MsgBox "Sorry, couldn't find " & strFind & " in that range."
End If
'clean up
Set rngFind = Nothing
Set rngStart = Nothing
Set rngFound = Nothing
strFind = vbNullString
End Sub

--
Kind Regards,
Will Riley


"Nigel" wrote:

Hi,
i am really struggling to create a macro to carry out the following.
( i am quite new to this and presently using a book but things are explained
fully!)

lets say cell K12 = 2245
i have a range of A2:A50 containing a list between 2220 & 2270

i need my macro to look at the value of K12. Find that value in range, and
make the cell with that value active
so in my list between 2220 & 2270 is an activecell where the value is 2245

i hope this can be done and hope that someone can help me.

Regards,

Nigel

  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

Don't know what happened with that post

With Worksheets(1).Range("A2:A50")
Set cell = .Find(Range("K12").Value, LookIn:=xlValues)
If Not cell Is Nothing Then
cell.Activate
End If
End With

--
HTH

Bob Phillips

"Bob Phillips" wrote in message
...
With Worksheets(1).Range("A2:A50") Set cell = .Find(Range("K12").Value,
LookIn:=xlValues) If Not cell Is Nothing Then cell.Activate

End
IfEnd With-- HTH
Bob Phillips

"Nigel" wrote in message
...
Hi,
i am really struggling to create a macro to carry out the following.
( i am quite new to this and presently using a book but things are

explained
fully!)

lets say cell K12 = 2245
i have a range of A2:A50 containing a list between 2220 & 2270

i need my macro to look at the value of K12. Find that value in range,

and
make the cell with that value active
so in my list between 2220 & 2270 is an activecell where the value is

2245

i hope this can be done and hope that someone can help me.

Regards,

Nigel







  #6   Report Post  
Jim May
 
Posts: n/a
Default

Bob: On a smaller scale I've set up some data, as follows and run:

Private Sub CommandButton1_Click()
Dim cell As Range
With Worksheets(1).Range("A2:A16")
Set cell = .Find(Range("D3").Value, LookIn:=xlValues)
If Not cell Is Nothing Then
cell.Activate
End If
End With
End Sub

As I step thru the code After Line 4 Set Cell -- Cell = Nothing...??
What am I missing?
Jim

"Bob Phillips" wrote in message
...
Don't know what happened with that post

With Worksheets(1).Range("A2:A50")
Set cell = .Find(Range("K12").Value, LookIn:=xlValues)
If Not cell Is Nothing Then
cell.Activate
End If
End With

--
HTH

Bob Phillips

"Bob Phillips" wrote in message
...
With Worksheets(1).Range("A2:A50") Set cell =

..Find(Range("K12").Value,
LookIn:=xlValues) If Not cell Is Nothing Then cell.Activate

End
IfEnd With-- HTH
Bob Phillips

"Nigel" wrote in message
...
Hi,
i am really struggling to create a macro to carry out the following.
( i am quite new to this and presently using a book but things are

explained
fully!)

lets say cell K12 = 2245
i have a range of A2:A50 containing a list between 2220 & 2270

i need my macro to look at the value of K12. Find that value in range,

and
make the cell with that value active
so in my list between 2220 & 2270 is an activecell where the value is

2245

i hope this can be done and hope that someone can help me.

Regards,

Nigel







  #7   Report Post  
Jim May
 
Posts: n/a
Default

Further in Cell A12 I have 2245 and in D3 I have 2245.
In Cell A5 I have 456, si If I can D3 to 456,,, It works
In stepping thru Cell=456,
Strange...
TIA,

"Jim May" wrote in message
news:qq%he.6951$It1.5267@lakeread02...
Bob: On a smaller scale I've set up some data, as follows and run:

Private Sub CommandButton1_Click()
Dim cell As Range
With Worksheets(1).Range("A2:A16")
Set cell = .Find(Range("D3").Value, LookIn:=xlValues)
If Not cell Is Nothing Then
cell.Activate
End If
End With
End Sub

As I step thru the code After Line 4 Set Cell -- Cell = Nothing...??
What am I missing?
Jim

"Bob Phillips" wrote in message
...
Don't know what happened with that post

With Worksheets(1).Range("A2:A50")
Set cell = .Find(Range("K12").Value, LookIn:=xlValues)
If Not cell Is Nothing Then
cell.Activate
End If
End With

--
HTH

Bob Phillips

"Bob Phillips" wrote in message
...
With Worksheets(1).Range("A2:A50") Set cell =

.Find(Range("K12").Value,
LookIn:=xlValues) If Not cell Is Nothing Then cell.Activate

End
IfEnd With-- HTH
Bob Phillips

"Nigel" wrote in message
...
Hi,
i am really struggling to create a macro to carry out the

following.
( i am quite new to this and presently using a book but things are
explained
fully!)

lets say cell K12 = 2245
i have a range of A2:A50 containing a list between 2220 & 2270

i need my macro to look at the value of K12. Find that value in

range,
and
make the cell with that value active
so in my list between 2220 & 2270 is an activecell where the value

is
2245

i hope this can be done and hope that someone can help me.

Regards,

Nigel









  #8   Report Post  
Jim May
 
Posts: n/a
Default

OK, after Formatting all my number as General - Everything works;
I didn't figure the formatting (Comma, 2 decimals) 2,245.00 mattered,
but it must!!

"Jim May" wrote in message
news:_V%he.6954$It1.3559@lakeread02...
Further in Cell A12 I have 2245 and in D3 I have 2245.
In Cell A5 I have 456, si If I can D3 to 456,,, It works
In stepping thru Cell=456,
Strange...
TIA,

"Jim May" wrote in message
news:qq%he.6951$It1.5267@lakeread02...
Bob: On a smaller scale I've set up some data, as follows and run:

Private Sub CommandButton1_Click()
Dim cell As Range
With Worksheets(1).Range("A2:A16")
Set cell = .Find(Range("D3").Value, LookIn:=xlValues)
If Not cell Is Nothing Then
cell.Activate
End If
End With
End Sub

As I step thru the code After Line 4 Set Cell -- Cell = Nothing...??
What am I missing?
Jim

"Bob Phillips" wrote in message
...
Don't know what happened with that post

With Worksheets(1).Range("A2:A50")
Set cell = .Find(Range("K12").Value, LookIn:=xlValues)
If Not cell Is Nothing Then
cell.Activate
End If
End With

--
HTH

Bob Phillips

"Bob Phillips" wrote in message
...
With Worksheets(1).Range("A2:A50") Set cell =

.Find(Range("K12").Value,
LookIn:=xlValues) If Not cell Is Nothing Then

cell.Activate
End
IfEnd With-- HTH
Bob Phillips

"Nigel" wrote in message
...
Hi,
i am really struggling to create a macro to carry out the

following.
( i am quite new to this and presently using a book but things are
explained
fully!)

lets say cell K12 = 2245
i have a range of A2:A50 containing a list between 2220 & 2270

i need my macro to look at the value of K12. Find that value in

range,
and
make the cell with that value active
so in my list between 2220 & 2270 is an activecell where the value

is
2245

i hope this can be done and hope that someone can help me.

Regards,

Nigel











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
Formula to return ADDRESS of cell in range that meets criteria Christie Excel Worksheet Functions 1 March 4th 05 11:13 PM
Find Max and Min based on cell reference gregork Excel Discussion (Misc queries) 3 February 21st 05 12:28 AM
Adding contents of one cell to a range of cells. CLJinVA Excel Worksheet Functions 1 February 10th 05 10:19 PM
make cell contents equal to null value - not blank, but empty mpierre Excel Worksheet Functions 1 December 29th 04 06:57 AM
Returning a Value to a Cell Based on a Range of Uncertain Size amc422 Excel Worksheet Functions 7 November 14th 04 03:03 PM


All times are GMT +1. The time now is 01:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"