Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
LSB LSB is offline
external usenet poster
 
Posts: 8
Default Problem with FIND

Hi Experts out there,

Currently I'm having a problem with the the Find function
in VBA. I am actually looking for a cell in another
sheet, but I always get nothing in the range. Can
somebody please help on what is wrong with my code below?

Public Sub finding()

Dim rng As Range
Dim strRange As String
Dim FindText As String

Let strRange = "CB"
Worksheets("CurrentBalance").Range("CB").Select
Let FindText = "23-01-2004"
With Worksheets("CurrentBalance").Range(strRange)
Set rng = .Find(What:="23-01-2004")
End With

If Not rng Is Nothing Then
rng.Activate
Else
MsgBox "Not Found"
End If

End Sub

MANY THANKS IN ADVANCE....

LSB
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with FIND

Instead of having
Worksheets("CurrentBalance").Range("CB").Select

put

Worksheets("CurrentBalance").Activate

that made the code work for me.

Then just activate the other sheet afterwards.

Keith
www.kjtfs.com


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Problem with FIND

because you're looking for a Date instead of a text string or number, you need to use DATESERIAL to refer to it.
Look at the follow modified macro.

Public Sub finding()

Dim rng As Range
Dim strRange As String

strRange = "CB"
Worksheets("CurrentBalance").Range(strRange).Selec t
With Worksheets("CurrentBalance").Range(strRange)
Set rng = .Find(DateSerial(2004, 1, 23))
End With

If Not rng Is Nothing Then
rng.Select
Else
MsgBox "Not Found"
End If
End Sub

----- LSB wrote: -----

Hi Experts out there,

Currently I'm having a problem with the the Find function
in VBA. I am actually looking for a cell in another
sheet, but I always get nothing in the range. Can
somebody please help on what is wrong with my code below?

Public Sub finding()

Dim rng As Range
Dim strRange As String
Dim FindText As String

Let strRange = "CB"
Worksheets("CurrentBalance").Range("CB").Select
Let FindText = "23-01-2004"
With Worksheets("CurrentBalance").Range(strRange)
Set rng = .Find(What:="23-01-2004")
End With

If Not rng Is Nothing Then
rng.Activate
Else
MsgBox "Not Found"
End If

End Sub

MANY THANKS IN ADVANCE....

LSB

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
Problem with 'Find' Dave Excel Discussion (Misc queries) 5 December 15th 09 01:27 PM
Find/Replace Problem Ed B.[_2_] Excel Discussion (Misc queries) 0 August 16th 08 04:33 PM
Find and Replace problem brad547190 Excel Discussion (Misc queries) 1 April 17th 08 01:32 AM
problem with FIND cjsmith22 Excel Worksheet Functions 3 November 17th 05 11:03 PM
Nested Find problem MikeR[_2_] Excel Programming 1 July 14th 03 12:17 AM


All times are GMT +1. The time now is 10:45 AM.

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"