Switch from 2007 to 2010

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
Over the weekend I switched from xl 2007 to 2010. This exact code worked fine in 2007, but not in 2010 currently. As i step thru (F8) the red code line appears to be "flawed"; Any help appreciated...

Rich (BB code):
Sub foobar()   ' This is what's required for XL 2007
Dim fso As Object
Dim strName As String
Dim strArr(1 To 65536, 1 To 1) As String, i As Long
Dim searchTerm As String
searchTerm = Range("B3").Value
Const strDir As String = "C:\Users\Owner\Documents\Trusted_Locations"
Range("B4:B7000").ClearContents
strName = Dir$(strDir & "\*" & searchTerm & "*.xls?")
Do While strName <> vbNullString
     i = i + 1
     strArr(i, 1) = Mid(strDir & "\" & strName, 37, 99)
     strName = Dir$()
Loop
fCount = i
MsgBox "Found " & fCount & " Files"
If i > 0 Then
    Range("B4").Resize(i).Value = strArr
End If
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,216,165
Messages
6,129,250
Members
449,497
Latest member
The Wamp

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