Vba Sayfa Silme

Katılım
27 Ocak 2021
Mesajlar
98
Excel Vers. ve Dili
2019 turkce
merhabalar PERSONEL isimli sayfadaki
A2 VE A son satır aralığındaki hücrelerde yazan isimlerle aynı olan çalışma sayfalarını sildirmek istiyorum yardımcı olabilirmisiniz?
 
Merhaba,

Deneyiniz.

C++:
Option Explicit

Sub Delete_Sheets()
    Dim Rng As Range, Sh As Worksheet, Last_Row As Long
    
    Application.DisplayAlerts = False
    
    Last_Row = Sheets("PERSONEL").Range("A" & Rows.Count).End(3).Row
    
    For Each Rng In Sheets("PERSONEL").Range("A2:A" & Last_Row)
        On Error Resume Next
        Set Sh = Nothing
        Set Sh = Sheets(CStr(Rng.Value))
        On Error GoTo 0
        
        If Not Sh Is Nothing Then
            If Sh.Name <> "PERSONEL" Then Sh.Delete
        End If
    Next
    
    Application.DisplayAlerts = True
    
    MsgBox "İşleminiz tamamlanmıştır.", vbInformation
End Sub
 
Merhaba,

Deneyiniz.

C++:
Option Explicit

Sub Delete_Sheets()
    Dim Rng As Range, Sh As Worksheet, Last_Row As Long
   
    Application.DisplayAlerts = False
   
    Last_Row = Sheets("PERSONEL").Range("A" & Rows.Count).End(3).Row
   
    For Each Rng In Sheets("PERSONEL").Range("A2:A" & Last_Row)
        On Error Resume Next
        Set Sh = Nothing
        Set Sh = Sheets(CStr(Rng.Value))
        On Error GoTo 0
       
        If Not Sh Is Nothing Then
            If Sh.Name <> "PERSONEL" Then Sh.Delete
        End If
    Next
   
    Application.DisplayAlerts = True
   
    MsgBox "İşleminiz tamamlanmıştır.", vbInformation
End Sub
Çok Teşşekkür ederim güzel çalışıyor
 
Geri
Üst