Verifica presenza file in sottocartelle dato percorso cartella principale e nomefile

Davide78

New Member
Joined
Apr 20, 2023
Messages
16
Office Version
  1. 2019
Platform
  1. Windows
Buongiorno, vorrei riuscire effettuare delle verifiche di presenza file in sottocartelle.
La situazione è la seguente:
  • C’è una cartella principale dove sono presenti delle sottocartelle contenenti dei file con architettura del nome specifica.
  • Nella cartella principale c’è un excel che funge da elenco documenti dove in una certa colonna c’è il nome codificato del documento.
L’idea sarebbe quella di usare una formula a fianco di ogni cella contenente il codice, ma credo non sia possibile e si debba per forza usare codice VBA, corretto?

Saluti
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Queste formule potrebbero essere una soluzione ma necessitano di una Function (UDF) da mettere in un modulo standard VBE.
Presumendo che il percorso ed il solo nome del file sia in cella D1 in F1 incollare: =SE(FileEsistente(D1 & ".xlsx");"File Presente";"File Mancante")
mentre se in D1 il file è completo di percorso, nome ed estensione in F1 si deve usare: =SE(FileEsistente(D1);"File Presente";"File Mancante")
Se il percorso non è presente nella cella D1 questo va inserito direttamente nella formula prima del D1 che si trova tra le parentesi.
La Function comune ad entrambe le soluzioni è:
VBA Code:
Function FileEsistente(FilePath As String)
    FileEsistente = Dir(FilePath) <> ""
End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,535
Members
449,169
Latest member
mm424

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