Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default select cell based on two searches

I am trying to select a cell on another sheet as follows:

searche Sheet2 for the text located in Sheet1 A1.
(I can do this first step)

Now, I want to search only the column of the previous search result for text
located in Sheet1 A2.

I have used this code which I found in a previous post to do the first part
of the search.

x = ActiveCell
y = Sheets("monthly budget").Cells.Find(x).Address
Application.Goto Sheets("monthly budget").Range(y), Scroll:=True

I have also stumbled around with my limited knowledge and have accomplished
my desired result, but it is very messy and requires jumping back and forth
from sheet to sheet with copying and pasting. I know there has to be a better
way.

thanks in advance,

Melissa
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default select cell based on two searches

Sub FindTwice()
dim rng1 as Range, rng2 as range
Dim rng3 as Range, rng4 as Range
set rng1 = Worksheets("Sheet1").Range("A1")
set rng2 = Worksheets("Sheet1").Range("A2")
set rng3 = Worksheets("Sheet2").Cells.Fine(rng1.Value)
if not rng3 is nothing then
set rng4 = rng3.EntireColumn.Find(rng2.Value)
if not rng4 is nothing then
msgbox "found at " & rng4.Address(0,0,xlA1,true)
application.Goto rng4, True
else
msgbox rng2 & " was not found in column " & rng2.column
end if
else
msgbox rng1 & " was not found"
End if
End Sub

--
Regards,
Tom Ogilvy



"beauty_bobaloo" wrote in message
...
I am trying to select a cell on another sheet as follows:

searche Sheet2 for the text located in Sheet1 A1.
(I can do this first step)

Now, I want to search only the column of the previous search result for

text
located in Sheet1 A2.

I have used this code which I found in a previous post to do the first

part
of the search.

x = ActiveCell
y = Sheets("monthly budget").Cells.Find(x).Address
Application.Goto Sheets("monthly budget").Range(y), Scroll:=True

I have also stumbled around with my limited knowledge and have

accomplished
my desired result, but it is very messy and requires jumping back and

forth
from sheet to sheet with copying and pasting. I know there has to be a

better
way.

thanks in advance,

Melissa



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default select cell based on two searches

Thankyou Tom, that worked great! I think I need to try and track down A VB
book For Excel.
I really want to learn. I feel like I am always relying on someone elses
knowledge.

I am very greatful for your help.

Melissa.

"Tom Ogilvy" wrote:

Sub FindTwice()
dim rng1 as Range, rng2 as range
Dim rng3 as Range, rng4 as Range
set rng1 = Worksheets("Sheet1").Range("A1")
set rng2 = Worksheets("Sheet1").Range("A2")
set rng3 = Worksheets("Sheet2").Cells.Fine(rng1.Value)
if not rng3 is nothing then
set rng4 = rng3.EntireColumn.Find(rng2.Value)
if not rng4 is nothing then
msgbox "found at " & rng4.Address(0,0,xlA1,true)
application.Goto rng4, True
else
msgbox rng2 & " was not found in column " & rng2.column
end if
else
msgbox rng1 & " was not found"
End if
End Sub

--
Regards,
Tom Ogilvy



"beauty_bobaloo" wrote in message
...
I am trying to select a cell on another sheet as follows:

searche Sheet2 for the text located in Sheet1 A1.
(I can do this first step)

Now, I want to search only the column of the previous search result for

text
located in Sheet1 A2.

I have used this code which I found in a previous post to do the first

part
of the search.

x = ActiveCell
y = Sheets("monthly budget").Cells.Find(x).Address
Application.Goto Sheets("monthly budget").Range(y), Scroll:=True

I have also stumbled around with my limited knowledge and have

accomplished
my desired result, but it is very messy and requires jumping back and

forth
from sheet to sheet with copying and pasting. I know there has to be a

better
way.

thanks in advance,

Melissa




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
Select a cell based on an other cell's value wally_91 Excel Worksheet Functions 4 March 13th 08 12:24 AM
Getting valid web searches and avoiding sites that contaminate web searches David McRitchie New Users to Excel 1 June 13th 06 03:00 AM
how to select a Row based on contents of a Cell swintronix Excel Programming 8 January 5th 06 11:52 PM
select a cell based on A1 contents Bill Kuunders Excel Programming 2 August 24th 05 11:23 PM
Select sheet based on cell value Dan Mills Excel Programming 2 January 14th 04 05:55 PM


All times are GMT +1. The time now is 10:02 AM.

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"