Hello,
is it possible to complete this code for MS Excel 2013, so when macro runs, it actually asks for folder, but when selected it would be good that when looping through main folder (that was chosen) it loops in all folders and subfolders and execute simple macro (that is in the code already)
Just tell me where to put what (or edit the code and embedd it) so it works. Waiting for any ideas. Thanks in advance
is it possible to complete this code for MS Excel 2013, so when macro runs, it actually asks for folder, but when selected it would be good that when looping through main folder (that was chosen) it loops in all folders and subfolders and execute simple macro (that is in the code already)
VBA Code:
Sub LoopThroughFiles()
Dim xFd As FileDialog
Dim xFdItem As Variant
Dim xFileName As String
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
If xFd.Show = -1 Then
xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
xFileName = Dir(xFdItem & "*.xls*")
Do While xFileName <> ""
With Workbooks.Open(xFdItem & xFileName)
'your code here
Columns("B:B").Select
Selection.EntireColumn.Hidden = True
Rows("1:1").Select
Range("C1").Activate
Selection.EntireRow.Hidden = True
Range("C14").Select
ActiveWorkbook.Save
End With
xFileName = Dir
Loop
End If
End Sub
Just tell me where to put what (or edit the code and embedd it) so it works. Waiting for any ideas. Thanks in advance