EXCEL TOOLS
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
[code]
และปิดด้วย [/code]
ตัวอย่างเช่น [code]dim r as range[/code]
เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)Code: Select all
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
Code: Select all
'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
Sheet1Sheet2Sheet(1)
ให้ครอบคลุมถึงชื่อชีตที่ไม่ต้องการ