Hello all,
I have some code that runs a loop. When I press the green 'run' button or F5, nothing happens at all.
I don't think there are any errors in my code, but maybe it is the case that there is a line that I need to include/move.
The loop opens docs one-by-one in a folder, changes the format the exact same way for each sheet per doc, saves the doc and closes the file.
I cannot find how to format my code into a proper format too...sorry about this.
'Loop
Path = "File_path" (omitted for privacy)
Filename = Dir(Path & "*.xl*")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename
'Enable editing
If Not Application.ActiveProtectedViewWindow Is Nothing Then
Application.ActiveProtectedViewWindow.Edit
End If
For Each Sheet In ActiveWorkbook.Sheets
'Run macro in loop
ActiveSheet.Pictures.Delete
Rows("1:6").Select
Range("A6").Activate
Selection.Delete Shift:=xlUp
Columns("F:F").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("F1").Select
ActiveCell.FormulaR1C1 = "Description"
Range("F3").Select
ActiveCell.FormulaR1C1 = ActiveWorkbook.Name
Range("E3").Select
Selection.Copy
Range("F3").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("$A$1:$V$1000").AutoFilter Field:=7, Criteria1:="0"
Range("A1").Select
Selection.Offset(1, 0).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$V$1000").AutoFilter Field:=7
ActiveSheet.Range("$A$1:$V$1000").AutoFilter Field:=11, Criteria1:="0"
Range("A1").Select
Selection.Offset(1, 0).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$V$1000").AutoFilter Field:=11
Range("A1").Select
Next Sheet
Sheet("Sheet1").Activate
Workbooks(Filename).Close SaveChanges:=True
Filename = Dir()
Loop
End Sub
Thanks for any help and advice in advance!
Lou
Bookmarks