Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default find a value in another sheet

following coding works find, however.....

Worksheets("a").select

Cells.Find(What:=zoek, After:=ActiveCell).Activate
rownr = ActiveCell.Row
colnr = ActiveCell.Column

if I don't use Worksheets("a").select and am located in a different sheet
e.g. worksheets("b").... it doesn't work. Is there a way to point to a
specific sheet from within the find command no matter in which worksheet you
are located at that time.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default find a value in another sheet

Hi

No need to select anything.
Look at this:

With Sheets("a")
Set f = .Cells.Find(what:=zoek, After:=ActiveCell)
If Not f Is Nothing Then
rownr = f.Row
colnr = f.Column
End If

Regards,
Per

On 20 Sep., 15:39, Luc wrote:
following coding works find, however.....

Worksheets("a").select

Cells.Find(What:=zoek, After:=ActiveCell).Activate
* *rownr = ActiveCell.Row
* *colnr = ActiveCell.Column

if I don't use Worksheets("a").select and am located in a different sheet
e.g. worksheets("b").... it doesn't work. *Is there a way to point to a
specific sheet from within the find command no matter in which worksheet you
are located at that time.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default find a value in another sheet


Thanks for the reply but doesn't really work wel.
zoek in the find statement is a variable and isn't being picked up!

Worksheets("a").select
zoek = "text"
Cells.Find(What:=zoek, After:=ActiveCell).Activate
rownr = ActiveCell.Row
colnr = ActiveCell.Column


any ideas?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default find a value in another sheet

I very rarely need to select an item beofre using it. I either include the
worksheet name in the instruction or use a with statement

with sheets("Sheet1")
set c = .Cells.Find(What:=zoek, After:=ActiveCell)
rownr = ActiveCell.Row
colnr = ActiveCell.Column

if c is nothing then
msgbox("Cannot Find : " & zoek)
else
c.activate
end with


or

set c = sheets("sheet1").Cells.Find(What:=zoek, After:=ActiveCell)
rownr = ActiveCell.Row
colnr = ActiveCell.Column

if c is nothing then
msgbox("Cannot Find : " & zoek)
else
c.activate

"Luc" wrote:

following coding works find, however.....

Worksheets("a").select

Cells.Find(What:=zoek, After:=ActiveCell).Activate
rownr = ActiveCell.Row
colnr = ActiveCell.Column

if I don't use Worksheets("a").select and am located in a different sheet
e.g. worksheets("b").... it doesn't work. Is there a way to point to a
specific sheet from within the find command no matter in which worksheet you
are located at that time.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default find a value in another sheet

I wouldn't use the activecell, either.

dim FoundCell as range
dim RowNr as long
dim ColNr as long
with worksheets("a")
set foundcell = .cells.find(what:=zoek,after:=.cells(.cells.count) ,....)
if foundcell is nothing then
'do nothing
else
rownr = foundcell.row
colnr = foundcell.column
end if
end with

ps. I would supply all the parms to that .find statement. If you don't, then
your .find will be inheriting the parms from the last find (xlwhole/xlpart,
matchcase, etc)--no matter if it was done in code or via the user interface.



Luc wrote:

following coding works find, however.....

Worksheets("a").select

Cells.Find(What:=zoek, After:=ActiveCell).Activate
rownr = ActiveCell.Row
colnr = ActiveCell.Column

if I don't use Worksheets("a").select and am located in a different sheet
e.g. worksheets("b").... it doesn't work. Is there a way to point to a
specific sheet from within the find command no matter in which worksheet you
are located at that time.


--

Dave Peterson


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
Find value in sheet 1 and copy matching row from sheet 2 Also Excel Programming 1 January 8th 08 11:49 AM
how can find sheet on workbook have so many sheet ? Huy Nguyen Excel Worksheet Functions 1 November 22nd 07 08:45 AM
Find value from sheet 1 on sheet 2 and copy to an offset from there L. Howard Kittle Excel Programming 3 March 2nd 07 09:32 PM
Find data from one sheet in another sheet [email protected] Excel Worksheet Functions 3 August 21st 06 07:08 PM
how to find and copy values on sheet 2, based on a list on sheet 1 evanmacnz Excel Programming 4 February 7th 05 08:33 PM


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