Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
cell.find not working
Hi
For some reason my code is returning the foundcell as true all the time even though the data is not there. If I do a manual find then it comes back as not found but with the code it comes back as found which is not correct. Below is the code I have, if anyone can give me some info on what to do to fix this probelm. stVoucherID = Application.Range("A" & dbnum).Value Sheets(2).Select Application.Range("F1").Select Set foundcell = Cells.Find(What:=stVoucherID, After:=ActiveCell, LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ True) If foundcell Is Nothing Then Sheets(3).Select Application.Range("a1").Select End if Thanks Noemi |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
cell.find not working
What does "stVoucherID" evaluate to ?
NickHK "Noemi" wrote in message ... Hi For some reason my code is returning the foundcell as true all the time even though the data is not there. If I do a manual find then it comes back as not found but with the code it comes back as found which is not correct. Below is the code I have, if anyone can give me some info on what to do to fix this probelm. stVoucherID = Application.Range("A" & dbnum).Value Sheets(2).Select Application.Range("F1").Select Set foundcell = Cells.Find(What:=stVoucherID, After:=ActiveCell, LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ True) If foundcell Is Nothing Then Sheets(3).Select Application.Range("a1").Select End if Thanks Noemi |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
cell.find not working
Hi Nick
StVoucherID is set as a string and stores numbers a text. However I worked out my problem, I need to add ActiveSheet before the Cells.Find as I am working over multiple sheets. thanks for your help anyway. Noemi "NickHK" wrote: What does "stVoucherID" evaluate to ? NickHK "Noemi" wrote in message ... Hi For some reason my code is returning the foundcell as true all the time even though the data is not there. If I do a manual find then it comes back as not found but with the code it comes back as found which is not correct. Below is the code I have, if anyone can give me some info on what to do to fix this probelm. stVoucherID = Application.Range("A" & dbnum).Value Sheets(2).Select Application.Range("F1").Select Set foundcell = Cells.Find(What:=stVoucherID, After:=ActiveCell, LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ True) If foundcell Is Nothing Then Sheets(3).Select Application.Range("a1").Select End if Thanks Noemi |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
cell.find not working
this works for me if i'm looking for the word test on sheet2. no need to select
the sheet Sub test() stVoucherID = "test" 'Application.Range("A" & dbnum).Value With Sheets(2) Set foundcell = .Cells.Find(What:=stVoucherID, LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=True) End With If foundcell Is Nothing Then Sheets(3).Select Application.Range("a1").Select Else MsgBox foundcell.Address End If End Sub -- Gary "Noemi" wrote in message ... Hi Nick StVoucherID is set as a string and stores numbers a text. However I worked out my problem, I need to add ActiveSheet before the Cells.Find as I am working over multiple sheets. thanks for your help anyway. Noemi "NickHK" wrote: What does "stVoucherID" evaluate to ? NickHK "Noemi" wrote in message ... Hi For some reason my code is returning the foundcell as true all the time even though the data is not there. If I do a manual find then it comes back as not found but with the code it comes back as found which is not correct. Below is the code I have, if anyone can give me some info on what to do to fix this probelm. stVoucherID = Application.Range("A" & dbnum).Value Sheets(2).Select Application.Range("F1").Select Set foundcell = Cells.Find(What:=stVoucherID, After:=ActiveCell, LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ True) If foundcell Is Nothing Then Sheets(3).Select Application.Range("a1").Select End if Thanks Noemi |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA Find and Replace isn't working on apostrophe within cell value | Excel Programming | |||
API to find position of active cell no longer working in 2007. | Excel Programming | |||
Loop to find next empty cell to the right not working. | Excel Programming | |||
Find Next is not working for me....... | Excel Programming | |||
.find with merged cell not working | Excel Programming |