网上找的代码。可简单批量处理excel。侵删。。。。将自己录制的宏替换蓝色字体那一行就好。测试了一下批量改字体,删除行列都可以,但是排序录制宏默认的是当前表格,对其他表格无效(所以并不是所有的都可以)楼主也是小白。并不清楚要如何修改。
Sub mysub() Dim ShApp As Object, mysheet As Object Dim TF As Boolean, i As Integer Dim aTable As Object, n As Integer On Error Resume Next n = 0 With Application.FileDialog(msoFileDialogFilePicker) .Title = "请选定要处理的excel文档" .Filters.Add "excel文档", "*.xls" '暂定扩展名为xls的excel文档 .AllowMultiSelect = True If .Show <> -1 Then Exit Sub Set ShApp = GetObject(, "Excel.Application") If Err <> 0 Then TF = True Set ShApp = CreateObject("Excel.Application") End If Application.ScreenUpdating = False For i = 1 To .SelectedItems.Count Set mysheet = ShApp.Workbooks.Open(.SelectedItems(i)) With mysheet.Sheets(1)
.range("a1:a6").entirerow.delete
End With n = n + 1 mysheet.Close True Next i End With If TF = True Then ShApp.Quit Set ShApp = Nothing MsgBox "处理完毕,共处理了" & n & "个excel文档。" Application.ScreenUpdating = True
End Sub
|