Replacing Application.FileSearch command for Excel 2010

wickitom

New Member
Joined
May 21, 2010
Messages
16
I have this in a Macro

Dim oSearch As FileSearch

Set oSearch = Application.FileSearch
With oSearch
.NewSearch
.LookIn = strDirName
.SearchSubFolders = False
' For example, to search for text files change this line to:
' .FileName "*.txt"
.Filename = "*.csv"
.Execute
CountAllFiles = .FoundFiles.Count
End With
End Function

how do I do the same in Excel 2010. I had the code above for Excel 2002.
It basically looks in the directory counts the number of files with *csv and gives me the number of those files.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

heliorq

New Member
Joined
Sep 4, 2015
Messages
2
Dears.
Ihave this sub in excel 203, but dont work in excel 2007 or 2010? Someone help me? thanks a lot in advanced.


Sub MostraPADTEC()


Range("15:16").Select
Selection.EntireRow.Hidden = False


Range("29:34").Select
Selection.EntireRow.Hidden = False

Range("17:22,23:28").Select
Selection.EntireRow.Hidden = True
Range("B30").Select

Dim Classeurs() As String, I As Long, Aux1 As Integer
With Application.FileSearch
.NewSearch
.FileType = msoFileTypeExcelWorkbooks ' p/ excel
'.FileType = msoFileTypeWordDocuments ' p/ word
'.FileType = msoFileTypePowerPointPresentations 'p/powerpoint
'.FileType = msoFileTypeOfficeFiles ' p/ todos
.Filename = "*.*" 'p/ txt
.LookIn = "C:\CIGR-DWDM\NIVEIS ÓPTICOS\SAPO\Entrada\PADTEC" ' localiza os arquivos contidos em C:\
.SearchSubFolders = True
.Execute
With .FoundFiles
ReDim Classeurs(1 To .Count, 1 To 2)
For I = 1 To .Count
Aux1 = Len(.Item(I)) - InStr(1, StrReverse(.Item(I)), "\")
Classeurs(I, 1) = Mid(.Item(I), 1, Aux1 + 1)
Classeurs(I, 2) = Mid(.Item(I), Aux1 + 2)
Next I
Application.ScreenUpdating = True
With Range("AC1000").Resize(.Count, 2)
.Value = Classeurs
.Sort [AC1000]
Range("A15").Select
End With
End With
End With


Range("B30:E30").Select
Selection.ClearContents
Range("B30").Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,186,814
Messages
5,959,972
Members
438,455
Latest member
kiran123

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
Top