Find A Value in Closed Workbook

FalconBLUE

New Member
Joined
Jan 3, 2008
Messages
11
Hi everybody,

I'm working on a project and came across a problem. I hope you have the solution. I want to find a selected person name and surname by textbox on a userform in closed workbook sheets. This workbook has 21 sub sheets. Actually, I wrote a code as below but didn't work. I think it should work but not. Where am I making mistake?

Code:
Sub AracListSIL()
Dim ArList As New Excel.Application
Dim nwb As New Excel.Workbook
Dim ws As Worksheet
Dim rFound As Range
Dim strName As String
Set nwb = ArList.Workbooks.Open("D:\Mega\Projects\ProjeMac\F iles\Arac_Listeleri.xlsx")
On Error Resume Next
strName = USERPERSONEL.txtAdSoyad 'adsoyad=name surname in textbox on userform
If strName = "" Then Exit Sub
For Each ws In ArList.Worksheets

With ws.UsedRange

For i = 1 To 60

Set rFound = ws.UsedRange.Find(what:=strName, After:=.Range("C" & i), SearchDirection:=xlNext, lookAt:=xlWhole)

If Not rFound Is Nothing Then
Application.Goto rFound, True
Exit Sub
End If
Next i
End With

Next ws
On Error GoTo 0

MsgBox "Value not found"

nwb.Save
nwb.Close
Set ArList = Nothing
Set nwb = Nothing
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,215,753
Messages
6,126,675
Members
449,327
Latest member
John4520

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top