Procurar nome em ficheiro de um directório
Enviado: 05 Mar 2017 às 12:19
por Andre309
Olá malta,
Ando aqui com um dilema e após várias pesquisas, ainda não consegui resolver.
Imaginem que tenho o nome "Domingo" na célula A1. O que eu queria fazer, era procurar num determinado directório se existe algum ficheiro com esta palavra no seu nome.
É possível fazer isto sem ser através de VBA? Só com fórmulas?
Re: Procurar nome em ficheiro de um directório
Enviado: 05 Mar 2017 às 12:40
por alexandrevba
Boa tarde!!
Para formulas veja:
https://trumpexcel.com/list-of-file-nam ... -in-excel/
Para VBA veja:
Código: Selecionar todosSub AleVBA_4209()
'Fonte: http://stackoverflow.com/questions/10380312/loop-through-files-in-a-folder-using-vba
Dim MyObj As Object, MySource As Object, file As Variant
file = Dir("C:\Users\AleVBA\Downloads\")
While (file <> "")
If InStr(file, "NomeDoArquivo") > 0 Then
MsgBox "Foi encontrado " & file
Exit Sub
End If
file = Dir
Wend
End Sub
Att
Re: Procurar nome em ficheiro de um directório
Enviado: 06 Mar 2017 às 08:19
por Andre309
alexandrevba escreveu:Boa tarde!!
Para formulas veja:
https://trumpexcel.com/list-of-file-nam ... -in-excel/
Para VBA veja:
Código: Selecionar todosSub AleVBA_4209()
'Fonte: http://stackoverflow.com/questions/10380312/loop-through-files-in-a-folder-using-vba
Dim MyObj As Object, MySource As Object, file As Variant
file = Dir("C:\Users\AleVBA\Downloads\")
While (file <> "")
If InStr(file, "NomeDoArquivo") > 0 Then
MsgBox "Foi encontrado " & file
Exit Sub
End If
file = Dir
Wend
End Sub
Att
Já tinha tentado esse método no meu PC, mas não estava a conseguir. tentei hoje no PC da empresa e funcionou correctamente.
Resolvido. Many thanks
