snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
n = Sheets.Count
Do While n > 0
r = Sheets(n).Name
If r = "Sheet" Then
Application.ScreenUpdating = False
Sheets(n).delete
Application.ScreenUpdating = True
End If
n = n - 1
Loop
You do not have the required permissions to view the files attached to this post.
'Other code
Dim sh As Worksheet
Set dbook = ThisWorkbook
With dbook.Worksheets("delete")
n = .Range("a" & .Rows.Count).End(xlUp).Offset(0, 0).Row
End With
Application.DisplayAlerts = False
For x = 1 To n
If dbook.Sheets("delete").Range("a1") > 0 Then
Set sbook = Workbooks.Open("C:\Users\Lenovo\Desktop\old\" & Range("a" & x) & ".xlsx", UpdateLinks:=False)
' n = Sheets.Count
' Do While n > 0
' r = Sheets(n).Name
' If r = "Sheet" Then
' Application.ScreenUpdating = False
' Sheets(n).delete
' Application.ScreenUpdating = True
' End If
' n = n - 1
' Loop
For Each sh In sbook.Worksheets
If InStr("Sheet1Sheet2Sheet(1)", sh.Name) > 0 Then
sh.Delete
End If
Next
End If
Next x
Application.DisplayAlerts = True
'Other code