Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding a value and going to that cell?


Hi all, is it possible to search for a value or name through an array of
sheets(for now lets say sheets 1 - 3) and when that value or name is
found go to that cell no matter which sheet, if more than 1 sheet is
found with the value give the option to move on to subsequent sheets or
stay with the first sheet it stopped at?

I'm probably asking a bit much on this one!

Hope you can help!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=552555

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Finding a value and going to that cell?

Here is a macro that finds the word Tada in sheets 1 and 2.

Sub FindStuff()
Dim colWks As Collection
Dim wks As Worksheet
Dim rng As Range
Dim strFirst As String

Set colWks = New Collection
colWks.Add Sheets("Sheet1"), Sheets("Sheet1").Name
colWks.Add Sheets("Sheet2"), Sheets("Sheet2").Name

For Each wks In colWks
Set rng = wks.Cells.Find(What:="Tada", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=False)
If Not rng Is Nothing Then
strFirst = rng.Address
Do
wks.Select
rng.Select
If MsgBox("How about this one...", vbYesNo, "Found One") =
vbYes Then _
Exit Sub
Set rng = wks.Cells.FindNext(rng)
Loop Until rng.Address = strFirst
End If
Next wks
MsgBox "Sorry, that was all of them", vbInformation, "All Done"
End Sub

--
HTH...

Jim Thomlinson


"Simon Lloyd" wrote:


Hi all, is it possible to search for a value or name through an array of
sheets(for now lets say sheets 1 - 3) and when that value or name is
found go to that cell no matter which sheet, if more than 1 sheet is
found with the value give the option to move on to subsequent sheets or
stay with the first sheet it stopped at?

I'm probably asking a bit much on this one!

Hope you can help!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=552555


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding a value and going to that cell?


Hi Jim Thanks for the reply, i had to add an End If before Loop Unti
but other than that it worked, i added an input box at the begining t
decide which string to search for, your code brought up the message bo
but without any content (i would like to show the contents of the cel
it found here) and when i clicked yes it did not transport me to th
cell that contained the one i said yes to......is it possible you coul
have a look at it and see if the above additions are possible?

Kind regards,
Simo

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=55255

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Finding a value and going to that cell?

You could get away without the end if but the code wrapped when I posted it.
Here is a slightly modified version of the procedure.

Sub FindStuff()
Dim colWks As Collection
Dim wks As Worksheet
Dim rng As Range
Dim strFirst As String

Set colWks = New Collection
colWks.Add Sheets("Sheet1"), Sheets("Sheet1").Name
colWks.Add Sheets("Sheet2"), Sheets("Sheet2").Name
application.screenupdating = true

For Each wks In colWks
Set rng = wks.Cells.Find(What:="Tada", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=False)
If Not rng Is Nothing Then
strFirst = rng.Address
Do
wks.Select
rng.Select
If MsgBox("How about this one... " & rng.Text, _
vbYesNo, "Found One") = vbYes Then _
Exit Sub
Set rng = wks.Cells.FindNext(rng)
Loop Until rng.Address = strFirst
End If
Next wks
MsgBox "Sorry, that was all of them", vbInformation, "All Done"
End Sub

--
HTH...

Jim Thomlinson


"Simon Lloyd" wrote:


Hi Jim Thanks for the reply, i had to add an End If before Loop Until
but other than that it worked, i added an input box at the begining to
decide which string to search for, your code brought up the message box
but without any content (i would like to show the contents of the cell
it found here) and when i clicked yes it did not transport me to the
cell that contained the one i said yes to......is it possible you could
have a look at it and see if the above additions are possible?

Kind regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=552555


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding a value and going to that cell?


Jim, thanks for the revised code i am still using the input box to find
the text and it works a treat, thanks for your efforts!

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=552555

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
finding last non-blank cell and then copying it to the next cell mike_vr Excel Discussion (Misc queries) 0 January 17th 08 05:02 PM
Finding Corresponding Cell Value Ken Excel Discussion (Misc queries) 2 August 19th 07 03:49 PM
Finding Cell Interior Colour of First Cell in Column ExcelMonkey[_190_] Excel Programming 4 March 22nd 05 03:01 AM
finding a cell rbekka33[_18_] Excel Programming 0 September 23rd 04 10:25 AM
finding a cell rbekka33[_17_] Excel Programming 1 September 23rd 04 10:17 AM


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