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: 7
Default Problem with find method

I have the following code that looks for dates from an array that may
already exist in a worksheet. When I test this code with a date in the array
already put inthe worksheet the find results in nothing;

what needs to be corrected?

'load the dates in row B into the array

Dim dtArray() As Date ' capture the selected dates
Dim icol as Integer
Dim ColCount as Integer
Dim Colstep as Integer
Dim i As Integer
Dim c as Range

ReDim dtArray(ColCount)
For iCol = 1 To ColCount Step 1
dtArray(iCol) = Cells(2, Colstep).Value
Colstep = Colstep + 1
Next iCol

' check if these dates were previously processed
Worksheets("datecontrol").Activate
With ActiveSheet.Usedrange ' the dates should be in Col A & it doesn't
matter if I use Range("A:A") or put the date in A2 and say .Range("A2")
For i = LBound(dtArray) To UBound(dtArray)
Set c = .Find(what:=dtArray(i), Lookat:=xlWhole)
If Not c Is Nothing Then
' c always ends up being "Nothing"
MsgBox "This date may have been processed; " & c.Value & "
terminating program"
Application.ScreenUpdating = True
Exit Sub
End If

Next i
End With


 
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
Find Method problem in Excel VBA.... Irmann Excel Worksheet Functions 7 March 10th 08 03:49 AM
Find Method ExcelMonkey[_190_] Excel Programming 1 March 18th 05 03:44 PM
range.find method called into a VBA function (problem) Eros Pedrini Excel Programming 5 November 17th 04 12:34 PM
Find Method LiSa Excel Programming 4 August 17th 04 04:10 PM
The Find Method Brad[_7_] Excel Programming 0 July 16th 03 03:23 PM


All times are GMT +1. The time now is 06:54 AM.

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"