Sub DeleteLastRowFromFirstSheetInFolder()
Dim folderPath As String
Dim fileName As String
Dim wb As Workbook
Dim ws As Worksheet
Dim lastRow As Long
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
folderPath = "F:\两项补贴\1"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(folderPath)
For Each objFile In objFolder.Files
If LCase(Right(objFile.Name, 4)) = ".xls" Or LCase(Right(objFile.Name, 5)) = ".xlsx" Then
Set wb = Workbooks.Open(objFile.Path)
Set ws = wb.Sheets(1)
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
If lastRow > 1 Then
ws.Rows(lastRow).Delete
End If
wb.Close SaveChanges:=True
End If
Next objFile
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing
End Sub