Çözüldü Excel dosyasının formülsüz ve makrosuz kopyasını oluşturma

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
41,510
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Merhaba,

Bende ilk mesajınızdaki dosyada denemiştim ve olumlu sonuç aldım. Eğer sizin uyguladığınız dosyada sayfalarda formül ve koşullu biçimlendirme yoksa hata vermesi normaldir. Koda hata kontrolleri eklemek gerekecektir.

Hata kontrolleri eklenmiş kodu deneyebilirsiniz.

Kod:
Option Explicit

Sub Formulsuz_ve_Makrosuz_Yedek_Olustur()
    Dim K1 As Workbook, Yedek As Workbook, Sayfa As Worksheet
    Dim Grafik As ChartObject, Alan As Range, Yol As String, Dosya_Adi As String
    Dim Formul As Variant, Kosullu_Bicimlendirme As Variant
       
    Application.Calculate
   
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .DisplayAlerts = False
        .EnableEvents = False
    End With
       
    Set K1 = ThisWorkbook
   
    K1.Sheets.Copy
   
    Set Yedek = ActiveWorkbook
   
    For Each Sayfa In Yedek.Worksheets
        If Sayfa.Name <> "ÖNBİLGİ" Then
            For Each Grafik In Sayfa.ChartObjects
                If Sheets("ÖNBİLGİ").Range("F4").Value = "" Then
                    Grafik.Chart.ChartTitle.Caption = ""
                Else
                    Grafik.Chart.ChartTitle.Caption = Sheets("ÖNBİLGİ").Range("F4").Value
                End If
            Next
           
            Set Formul = Nothing
            On Error Resume Next
            Set Formul = Sayfa.Cells.SpecialCells(xlCellTypeFormulas)
            On Error GoTo 0
            If Not Formul Is Nothing Then
                With Sayfa
                    .Select
                    .Cells.Copy
                    .Cells.PasteSpecial xlPasteValues
                    .Cells(1).Select
                End With
                Application.CutCopyMode = False
            End If
           
            Set Kosullu_Bicimlendirme = Nothing
            On Error Resume Next
            Set Kosullu_Bicimlendirme = Sayfa.Cells.SpecialCells(xlCellTypeAllFormatConditions)
            On Error GoTo 0
            If Not Kosullu_Bicimlendirme Is Nothing Then
                For Each Alan In Kosullu_Bicimlendirme
                    Alan.Interior.ColorIndex = Alan.DisplayFormat.Interior.ColorIndex
                    Alan.Font.ColorIndex = Alan.DisplayFormat.Font.ColorIndex
                Next
                Sayfa.Cells.FormatConditions.Delete
            End If
           
        End If
    Next
   
    Yedek.Sheets("ÖNBİLGİ").Delete
    Yedek.Sheets(1).Select
   
    Yol = K1.Path & Application.PathSeparator
    Dosya_Adi = "Yedek_" & Format(Date, "dd_mm_yy") & "_" & Format(Time, "hh_mm_ss") & ".xlsx"
   
    Yedek.SaveCopyAs Yol & Dosya_Adi
    Yedek.Close False
   
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .DisplayAlerts = True
        .EnableEvents = True
    End With
   
    MsgBox "Dosyanız aşağıdaki klasöre formülsüz ve makrosuz olarak yedeklenmiştir." & vbCrLf & vbCrLf & _
           Yol & Dosya_Adi, vbInformation
End Sub
 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,760
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
Kitap 1 için kod

Kod:
Sub deneme()
Klasor = ThisWorkbook.Path

ReDim tarih1(14)
ReDim tarih2(14)
tarih1(1) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(30, "e").Value
tarih1(2) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(31, "e").Value
tarih1(3) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(32, "e").Value
tarih1(4) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(33, "e").Value
tarih1(5) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(34, "e").Value
tarih1(6) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(35, "e").Value
tarih1(7) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(36, "e").Value

tarih1(8) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(41, "e").Value
tarih1(9) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(42, "e").Value
tarih1(10) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(43, "e").Value
tarih1(11) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(44, "e").Value
tarih1(12) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(45, "e").Value
tarih1(13) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(46, "e").Value
tarih1(14) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(47, "e").Value

tarih2(1) = 41
tarih2(2) = 41
tarih2(3) = 41
tarih2(4) = 41
tarih2(5) = 41
tarih2(6) = 41
tarih2(7) = 41

tarih2(8) = 43
tarih2(9) = 43
tarih2(10) = 43
tarih2(11) = 43
tarih2(12) = 43
tarih2(13) = 43
tarih2(14) = 43


With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With
git = ActiveSheet.Name

Dim myArray() As Variant
Dim i As Integer
Dim j As Integer
j = 0
For i = 1 To Sheets.Count
r = 1
If Sheets(i).Name = "ÖNBİLGİ" Then
r = 0
End If

If r = 1 Then
ReDim Preserve myArray(j)
myArray(j) = i
j = j + 1
End If

Next i

Sheets(myArray).Select
Sheets(myArray).Copy
yenidosya_adı = ActiveWorkbook.Name

Dim fL As Object
Set fL = CreateObject("Scripting.FileSystemObject")
Dosya_Adi = fL.GetBaseName(ThisWorkbook.Name) 'dosya adı
uzanti = "." & fL.GetExtensionName(ThisWorkbook.Name) 'uzanti

If uzanti = ".xls" Then
FileFormatNum = -4143
ElseIf uzanti = ".xlsx" Then
FileFormatNum = 51
ElseIf uzanti = ".xlsm" Then
FileFormatNum = 52
ElseIf uzanti = ".xlsb" Then
FileFormatNum = 50
ElseIf uzanti = ".xls" Then
FileFormatNum = 56
End If

sat = CreateObject("Scripting.FileSystemObject").GetFolder(Klasor).Files.Count + 1

deger = "Yeni" & Dosya_Adi & sat & uzanti
For i = 1 To ActiveWorkbook.Sheets.Count
ActiveWorkbook.Sheets(Sheets(i).Name).Select
ActiveWorkbook.Sheets(Sheets(i).Name).Cells.Copy
ActiveWorkbook.Sheets(Sheets(i).Name).Range("a1").PasteSpecial Paste:=3

Application.CutCopyMode = False
ActiveWorkbook.Sheets(Sheets(i).Name).Cells.FormatConditions.Delete
s = 0
For k = 27 To 46
s = s + 1
deg = ActiveWorkbook.Sheets(Sheets(i).Name).Cells(k, "a").Value
tarih = CDate(ActiveWorkbook.Sheets(Sheets(i).Name).Cells(k, "a").Value)

For m = 1 To 14
If tarih = tarih1(m) Then
ActiveWorkbook.Sheets(Sheets(i).Name).Range(Cells(k, "a"), Cells(k, "j")).Interior.ColorIndex = tarih2(m)
GoTo atla
End If

If Format((tarih), "dd") = "15" Then
ActiveWorkbook.Sheets(Sheets(i).Name).Range(Cells(k, "a"), Cells(k, "j")).Interior.ColorIndex = 48
GoTo atla
End If
Next m

atla:

Next k


ActiveWorkbook.Sheets(Sheets(i).Name).Cells.FormatConditions.Delete
Range("A2").Select
'ActiveSheet.DrawingObjects.Delete
Application.CutCopyMode = False
Next

For Each Component In ActiveWorkbook.VBProject.VBComponents
If Component.Type <> 100 Then
ActiveWorkbook.VBProject.VBComponents.Remove Component
Else
Set modul = Component.CodeModule
modul.DeleteLines 1, modul.CountOfLines
End If
Next

ActiveWorkbook.Sheets(Sheets(1).Name).Select
ActiveWorkbook.SaveAs Klasor & "\" & deger, FileFormat:=FileFormatNum

ActiveWorkbook.Close SaveChanges:=False
Sheets(git).Select

With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
MsgBox Klasor & "\" & deger & Chr(10) & Chr(10) & _
"Kayıt yapıldı", vbInformation, deger

End Sub
 

halit3

Uzman
Uzman
Katılım
18 Ocak 2008
Mesajlar
12,760
Excel Vers. ve Dili
2003 excell türkçe
ve
2007 excell türkçe
Kitap2 ye ait kod

Kod:
Sub deneme2()
Klasor = ThisWorkbook.Path

ReDim tarih1(14)
ReDim tarih2(14)
tarih1(1) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(40, "d").Value
tarih1(2) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(41, "d").Value
tarih1(3) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(42, "d").Value
tarih1(4) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(43, "d").Value
tarih1(5) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(44, "d").Value
tarih1(6) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(45, "d").Value
tarih1(7) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(46, "d").Value

tarih1(8) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(51, "d").Value
tarih1(9) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(52, "d").Value
tarih1(10) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(53, "d").Value
tarih1(11) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(54, "d").Value
tarih1(12) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(55, "d").Value
tarih1(13) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(56, "d").Value
tarih1(14) = ActiveWorkbook.Sheets("ÖNBİLGİ").Cells(57, "d").Value

tarih2(1) = 41
tarih2(2) = 41
tarih2(3) = 41
tarih2(4) = 41
tarih2(5) = 41
tarih2(6) = 41
tarih2(7) = 41

tarih2(8) = 43
tarih2(9) = 43
tarih2(10) = 43
tarih2(11) = 43
tarih2(12) = 43
tarih2(13) = 43
tarih2(14) = 43


With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With
git = ActiveSheet.Name

Dim myArray() As Variant
Dim i As Integer
Dim j As Integer
j = 0
For i = 1 To Sheets.Count
r = 1
If Sheets(i).Name = "ÖNBİLGİ" Then
r = 0
End If

If r = 1 Then
ReDim Preserve myArray(j)
myArray(j) = i
j = j + 1
End If

Next i

Sheets(myArray).Select
Sheets(myArray).Copy
yenidosya_adı = ActiveWorkbook.Name

Dim fL As Object
Set fL = CreateObject("Scripting.FileSystemObject")
Dosya_Adi = fL.GetBaseName(ThisWorkbook.Name) 'dosya adı
uzanti = "." & fL.GetExtensionName(ThisWorkbook.Name) 'uzanti

If uzanti = ".xls" Then
FileFormatNum = -4143
ElseIf uzanti = ".xlsx" Then
FileFormatNum = 51
ElseIf uzanti = ".xlsm" Then
FileFormatNum = 52
ElseIf uzanti = ".xlsb" Then
FileFormatNum = 50
ElseIf uzanti = ".xls" Then
FileFormatNum = 56
End If

sat = CreateObject("Scripting.FileSystemObject").GetFolder(Klasor).Files.Count + 1

deger = "Yeni" & Dosya_Adi & sat & uzanti
For i = 1 To ActiveWorkbook.Sheets.Count
ActiveWorkbook.Sheets(Sheets(i).Name).Select
ActiveWorkbook.Sheets(Sheets(i).Name).Cells.Copy
ActiveWorkbook.Sheets(Sheets(i).Name).Range("a1").PasteSpecial Paste:=3

Application.CutCopyMode = False
ActiveWorkbook.Sheets(Sheets(i).Name).Cells.FormatConditions.Delete

If Right(Sheets(i).Name, 1) = "G" Then

For k = 4 To 29
If IsDate(ActiveWorkbook.Sheets(Sheets(i).Name).Cells(k, "a").Value) = True Then
tarih = CDate(ActiveWorkbook.Sheets(Sheets(i).Name).Cells(k, "a").Value)
For m = 1 To 14
If tarih = tarih1(m) Then
ActiveWorkbook.Sheets(Sheets(i).Name).Cells(k, "a").Interior.ColorIndex = tarih2(m)
GoTo atla
End If
Next m
atla:
End If

Next k
End If

ActiveWorkbook.Sheets(Sheets(i).Name).Cells.FormatConditions.Delete
Range("A2").Select
'ActiveSheet.DrawingObjects.Delete
Application.CutCopyMode = False
Next

For Each Component In ActiveWorkbook.VBProject.VBComponents
If Component.Type <> 100 Then
ActiveWorkbook.VBProject.VBComponents.Remove Component
Else
Set modul = Component.CodeModule
modul.DeleteLines 1, modul.CountOfLines
End If
Next

ActiveWorkbook.Sheets(Sheets(1).Name).Select
ActiveWorkbook.SaveAs Klasor & "\" & deger, FileFormat:=FileFormatNum

ActiveWorkbook.Close SaveChanges:=False
Sheets(git).Select

With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
MsgBox Klasor & "\" & deger & Chr(10) & Chr(10) & _
"Kayıt yapıldı", vbInformation, deger

End Sub
 
Son düzenleme:

MESUT K

Altın Üye
Katılım
26 Nisan 2019
Mesajlar
219
Excel Vers. ve Dili
İş'te:Excel 2016 eng
Ev'de:Excel 2013 tr
Altın Üyelik Bitiş Tarihi
29-04-2025
Merhaba,

Bende ilk mesajınızdaki dosyada denemiştim ve olumlu sonuç aldım. Eğer sizin uyguladığınız dosyada sayfalarda formül ve koşullu biçimlendirme yoksa hata vermesi normaldir. Koda hata kontrolleri eklemek gerekecektir.

Hata kontrolleri eklenmiş kodu deneyebilirsiniz.

Kod:
Option Explicit

Sub Formulsuz_ve_Makrosuz_Yedek_Olustur()
    Dim K1 As Workbook, Yedek As Workbook, Sayfa As Worksheet
    Dim Alan As Range, Yol As String, Dosya_Adi As String
    Dim Formul As Variant, Kosullu_Bicimlendirme As Variant
   
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .DisplayAlerts = False
        .EnableEvents = False
    End With
       
    Set K1 = ThisWorkbook
   
    K1.Sheets.Copy
   
    Set Yedek = ActiveWorkbook
   
    Yedek.Sheets("ÖNBİLGİ").Delete
   
    For Each Sayfa In Yedek.Worksheets
        Set Formul = Nothing
        On Error Resume Next
        Set Formul = Sayfa.Cells.SpecialCells(xlCellTypeFormulas)
        On Error GoTo 0
        If Not Formul Is Nothing Then
            With Formul
                .Value = .Value
            End With
        End If
       
        Set Kosullu_Bicimlendirme = Nothing
        On Error Resume Next
        Set Kosullu_Bicimlendirme = Sayfa.Cells.SpecialCells(xlCellTypeAllFormatConditions)
        On Error GoTo 0
        If Not Formul Is Nothing Then
            For Each Alan In Kosullu_Bicimlendirme
                Alan.Interior.ColorIndex = Alan.DisplayFormat.Interior.ColorIndex
            Next
            Sayfa.Cells.FormatConditions.Delete
        End If
    Next
   
    Yol = K1.Path & Application.PathSeparator
    Dosya_Adi = "Yedek_" & Format(Date, "dd_mm_yy") & "_" & Format(Time, "hh_mm_ss") & ".xlsx"
   
    Yedek.SaveCopyAs Yol & Dosya_Adi
    Yedek.Close False
   
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .DisplayAlerts = True
        .EnableEvents = True
    End With
   
    MsgBox "Dosyanız aşağıdaki klasöre formülsüz ve makrosuz olarak yedeklenmiştir." & vbCrLf & vbCrLf & _
           Yol & Dosya_Adi, vbInformation
End Sub
Koray Bey Kod ilk mesajımdaki dosyada düzgün çalışıyor.yeni kopya oluşuyor.formüller makrolar siliniyor.koşullar siliniyor.renkler kalıyor.(y)

Fakat ben başka bir dosyaya bu kodu uyguladığım zaman kod yeni kopyayı oluşturuyor.formül, koşul ,makro, renkleri siliyor ve hücre içeriklerini bozuyor
 

MESUT K

Altın Üye
Katılım
26 Nisan 2019
Mesajlar
219
Excel Vers. ve Dili
İş'te:Excel 2016 eng
Ev'de:Excel 2013 tr
Altın Üyelik Bitiş Tarihi
29-04-2025
Halit Bey kitap 1 de ilgili kod çalışıyor.yeni kopya oluşuyor.makrolar,formüller koşullar siliniyor,renkler gitmiyor(y)

kitap 2 de ilgili kod çalışıyor.yeni kopya oluşuyor.makrolar,formüller koşullar siliniyor,renkler gitmiyor(y) sadece kitap 2 de +3s,+2s,-2s,-3s' bulunduğu sütunun olduğu kısımda koşul renkleri silinmiş.Birde ben bu kodları şifreli sayfalara uygulamak istiyorum.
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
41,510
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Şu uyguladığınız dosyaları bizde görseydik deneme şansımız olurdu.
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
41,510
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
#41 nolu mesajımdaki kodu özelden gönderdiğiniz dosyalara göre yeniden düzenledim.

Deneyip sonucu bildirir misiniz?
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
41,510
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
2007 versiyonda deniyorsanız "DisplayFormat" özelliğini desteklemediği için hata alırsınız. Daha yüksek versiyonda deneyiniz.
 

MESUT K

Altın Üye
Katılım
26 Nisan 2019
Mesajlar
219
Excel Vers. ve Dili
İş'te:Excel 2016 eng
Ev'de:Excel 2013 tr
Altın Üyelik Bitiş Tarihi
29-04-2025
ilk denememi excel 2007 de yaptım.versiyondan şüphelendim.excel 2010 denedim aynı hatayı aldım.muhtemelen bu iki versiyon bu iş için cılız kalıyor
 
Üst