|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub batch_delete()
Dim mypath$, myname$, wkb As Workbook, wb As Workbook, sh As Worksheet, r As Range
Set wb = ThisWorkbook
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "请指定数据源所在的文件夹"
If .Show Then
mypath = .SelectedItems(1)
If Right(mypath, 1) <> "\" Then mypath = mypath & "\"
myname = Dir(mypath & "*.xls*")
Application.ScreenUpdati3ng = False
Do While Len(myname) <> 0
If myname <> wb.Name Then
Set wkb = Workbooks.Open(Filename:=mypath & myname, UpdateLinks:=False)
With wkb
On Error Resume Next
Set sh = .Sheets("订单")
If Err.Number <> 0 Then MsgBox "工作簿" & .Name & "中不存在订单工作表": End
Set r = sh.Range("B:V")
r.Delete shift:=xlToLeft
.Close True
End With
myname = Dir
End If
Loop
Application.ScreenUpdating = True
Else: MsgBox "还没有告诉我您的数据源在哪里!", , "提示": Exit Sub
End If
End With
MsgBox "恭喜,批量删除指定区域完成!", , "OK"
End Sub
|
评分
-
2
查看全部评分
-
|