Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error if text not found

I am trying to get a Excel-macro to lookup text in a cell on one worksheet
and find the same text in another worksheet.
It works fine until it reaches a text that can't be found on the other
worksheet.

This is my code
Dim Celle As String

Celle = ActiveCell
Sheets("Stykliste").Select
Cells.Find(What:=Celle, After:=[A1], SearchOrder:=xlByRows,
SearchDirection:=xlNext).Select


I get a "Run-time Error 91"

What am I doing wrong?

Regards
Jens Nielsen



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Error if text not found

try this. Change sheet6 to your sheetname

Sub findem()'from activecell on source sheet
Dim Celle As String
Dim x As Range
Celle = ActiveCell
x = Sheets("Sheet6").Cells.Find(What:=Celle, After:=[A1],
SearchOrder:=xlByRows, _
SearchDirection:=xlNext).Address

Application.Goto Sheets("sheet6").Range(x)
'usually NOT necessary to select

End Sub


--
Don Guillett
SalesAid Software

"Jens Nielsen" wrote in message
. dk...
I am trying to get a Excel-macro to lookup text in a cell on one worksheet
and find the same text in another worksheet.
It works fine until it reaches a text that can't be found on the other
worksheet.

This is my code
Dim Celle As String

Celle = ActiveCell
Sheets("Stykliste").Select
Cells.Find(What:=Celle, After:=[A1], SearchOrder:=xlByRows,
SearchDirection:=xlNext).Select


I get a "Run-time Error 91"

What am I doing wrong?

Regards
Jens Nielsen





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Error if text not found


try this instead

Sub findem()
Dim Celle As String
Celle = ActiveCell
x = Sheets("Sheet6").Cells.Find(What:=Celle, After:=[A1],
SearchOrder:=xlByRows, _
SearchDirection:=xlNext).Address
Application.Goto Sheets("sheet6").Range(x)
End Sub


--
Don Guillett
SalesAid Software

"Jens Nielsen" wrote in message
. dk...
I am trying to get a Excel-macro to lookup text in a cell on one worksheet
and find the same text in another worksheet.
It works fine until it reaches a text that can't be found on the other
worksheet.

This is my code
Dim Celle As String

Celle = ActiveCell
Sheets("Stykliste").Select
Cells.Find(What:=Celle, After:=[A1], SearchOrder:=xlByRows,
SearchDirection:=xlNext).Select


I get a "Run-time Error 91"

What am I doing wrong?

Regards
Jens Nielsen





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
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
error "module not found" Amit Excel Discussion (Misc queries) 1 May 13th 05 01:24 PM
The search key was not found error Nydia New Users to Excel 0 April 27th 05 03:09 PM
Path Not Found Error Ric Payne Excel Programming 0 October 29th 03 07:59 AM
Error Msg: 'No Cells were found' Stuart[_5_] Excel Programming 6 July 14th 03 05:57 PM


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