try:

Sub run_macro_on_all_files()
    
    Dim strPath As String
    Dim strFiles As String
    
    strPath = "C:\test\"
    If Not Dir(strPath & "*.txt") = "" Then 'test for existence of txt files
        strFiles = Dir(strPath & "*.txt")
        Do Until strFiles = ""
            'paste your code here
            '...
            '...
            '...
            strFiles = Dir
        Loop
    End If 

End Sub