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: 27
Default Find Next problem

Hello all,
Thank you for taking the time to look at this for me. I am a little bit
of a rookie at this and trying to learn as I continue.
Here is some code that I am working on and having an extemely hard time
in making it work.
I am having two probelms with it. First if the string that I am looking
for is in a1 it does not seem to find it. Next is the findnext routine,
it generates runtime error 1004 "Unable to get the findnext property of
the range class. I think that I have been matching what I have been
reading on this site?? Something misunderstood?
Any help would be appreciated. tia.
Terry
Sub find_files()
Dim filter As Variant
Dim wbk As Workbook, sh As Worksheet
Dim i As Single, rng As Range
Dim firstcell As String
Dim caption As String
Dim selectedfile As Variant
filter = "Excel files (*.xls), *.xls"
caption = "Select a File"
selectedfile = Application.GetOpenFilename(filter, , caption, _
, True)
Select Case IsArray(selectedfile)
Case True
For i = LBound(selectedfile) To UBound(selectedfile)
Set wbk = Workbooks.Open(selectedfile(i))
For Each sh In wbk.Worksheets
Set rng = Cells.Find(UserForm1.TextBox2.Text, _
LookIn:=xlValues, lookat:=xlWhole,
MatchCase:=False)
rng.Activate
Do
If Not rng Is Nothing Then
firstcell = rng.Address
MsgBox "Found " & UserForm1.TextBox2.Text & " in "
_
& wbk.Name & " on Sheet " & sh.Name & " in cell " &
rng.Address & vbCr & vbLf & "Continue?", vbYesNo, "Found your Text"
End If
Set rng = rng.FindNext(after:=firstcell).Activate
<<<<<<problem here
Loop Until ActiveCell.Address = firstcell
Next sh
wbk.Close (False)
Next i
Case False
MsgBox ("No Files Selected")
End Select

End Sub

 
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 cjsmith22 Excel Worksheet Functions 3 November 17th 05 11:03 PM
Find problem alanthecat Excel Programming 7 July 5th 05 01:17 PM
find problem John Excel Programming 4 July 3rd 04 08:30 AM
find problem jon Excel Programming 2 May 24th 04 11:27 AM
Problem with FIND LSB Excel Programming 2 January 12th 04 04:16 AM


All times are GMT +1. The time now is 07:31 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"