LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Cells.Find problem

I use Excel 2000 and Win2000.

I have two sheets in my workbook. One of the cells on the sheet called
"dummy" has the word "charge" in it.

This code in the click event for a button on the "dummy" sheet, finds
the cell with "charge":

Private Sub CommandButton1_Click()
Dim FoundCell As Range
Set FoundCell = Cells.Find(What:="charge", After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False)
If FoundCell Is Nothing Then
MsgBox "Not Found"
Else
MsgBox "Found"
End If
End Sub

However, this code in the click event for a button on my other sheet,
does not:

Private Sub CommandButton1_Click()
Dim FoundCell As Range
Sheets("dummy").Select ' only change from the code above
Set FoundCell = Cells.Find(What:="charge", After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False)
If FoundCell Is Nothing Then
MsgBox "Not Found"
Else
MsgBox "Found"
End If
End Sub

What am I doing wrong?

 
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
Compatibility alert - can't find cells causing problem odp Excel Discussion (Misc queries) 0 May 12th 09 02:50 AM
I have question.. I have problem with Cells.find Andrzej Excel Programming 7 May 27th 05 06:25 PM
I have question.. I have problem with Cells.find Andrzej New Users to Excel 0 May 27th 05 03:26 PM
INTRICATE PROBLEM- How to find multiple text,excluding "H", in a multiple range of cells, then replacing 0 with another number in another cell Tourcat Excel Worksheet Functions 1 February 8th 05 06:26 PM
Problem with cells.Find within a loop jowatkins Excel Programming 4 December 9th 03 01:39 PM


All times are GMT +1. The time now is 02:55 PM.

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"