Using VBA code to all files in folder

kowal666

New Member
Joined
May 15, 2017
Messages
1
I want to extract, from the ID column, the Telephone using:

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">Sub Left_Funcion()
Dim LResult As String
LResult
= "=Left(B2,11)"

With Sheets("Worksheet")
.Range("E2:E" & .Cells(.Rows.Count, "A").End(xlUp).Row).Formula = LResult
End With
End Sub</code>
WfStq.png


I can do it with one file, but what to do when I want to do this to multiple files in folder like C:\Users\kowal\Documents\TestResults
what code i must add to makro?



 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Set your folder path for sFolder variable.
Code:
Sub IterateFolder()


    Dim wkb As Workbook
    Dim sFile As String
    Const sFolder As String = "C:\Files\"
    
    sFile = Dir(sFolder)
    
    While Len(sFile)
        Set wkb = Workbooks.Open(sFolder & sFile)
        ' Your code
        sFile = Dir()
    Wend


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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