Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Counting instances of found text (Excel error? Or user error?) | Excel Worksheet Functions | |||
error "module not found" | Excel Discussion (Misc queries) | |||
The search key was not found error | New Users to Excel | |||
Path Not Found Error | Excel Programming | |||
Error Msg: 'No Cells were found' | Excel Programming |