• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Basit bir işlem neden bu kadar uzun surer.

  • Konbuyu başlatan Konbuyu başlatan Hurin
  • Başlangıç tarihi Başlangıç tarihi

Hurin

Altın Üye
Katılım
28 Haziran 2021
Mesajlar
13
Excel Vers. ve Dili
Excel 2013
Merhabalar, 6124 tane satır var; basit bir makro yazdım ancak anlam veremediğim şeklide uzun sürüyor, nedeni nedir sizce ? Nerede hata yapıyorum ? Şimdiden ilgililere teşekkür ederim.

Private Sub CommandButton4_Click()
On Error Resume Next
sonsatir = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To sonsatir
Cells(i, 92) = Cells(i, 23) - Cells(i, 23) / (Cells(i, 91) + 1)

Next i
End Sub
 
on error resume next
yukarıdaki satırı iptal edin ve hangi satırda hata oluşuyor gözlemleyin ve hatayı giderin.
 
Merhaba
Sıkıntı parantez de olabilirmi acaba, deneyiniz.
Cells(i, 92) = (Cells(i, 23) - Cells(i, 23) / Cells(i, 91)) + 1
 
Diğer sıkıntı kaynağı ,
Cells(i,23)-(cells,i 23) den çıkarıyor.
Çıkarılan aynı değer değilmi..
Cells(i, 92) = (Cells(i, 23) - Cells(i, 23) / Cells(i, 91)) + 1
 
Diğer sıkıntı kaynağı ,
Cells(i,23)-(cells,i 23) den çıkarıyor.
Çıkarılan aynı değer değilmi..
Cells(i, 92) = (Cells(i, 23) - Cells(i, 23) / Cells(i, 91)) + 1
Net değerinden, bölünmüş değerini çıkartıyor. Dediğiniz gibi parantezleri koydum ama yine işlem uzun sürüyor.
Daha karmaşık makrolar saniyeler içinde biterken nasıl oluyorsa normal bir matematik işlemi (vade farkı hesaplama) bu kadar uzun sürüyor anlamadım. :)
 
Muhtemelen veri satır sayınız çoktur ayrıca birbirine bağlı çok fazla formüllü hücre vardır. Makro sayfaya her veri işlediğinde tekrar tekrar hesaplama yapıldığı için işlem uzun sürüyordur. Bunu önlemek için sayfa olaylarını, hesaplamayı ve ekran yenilemeyi geçici olarak kapatabilirve makronun sonunda aktifleştirebilirsiniz.
 
on error resume next
yukarıdaki satırı iptal edin ve hangi satırda hata oluşuyor gözlemleyin ve hatayı giderin.
Yaptım ve hata çıkmadı, on error resume next başka bir işlemden kalmaydı (if) onu sildiğim halde hala anlamsız derecede işlem uzun sürüyor.
 
Yeni bir module ekleyerek aşağıdaki kodları ekleyiniz.
Kod:
Refer to Usage Example on how to use the code.

Public PriorCalcMode As Variant

Public Function TurnOnSpeed(x As Boolean)

'-----------------------------
'Thanks for downloading the code.
'Please visit our channel for a quick explainer on how to use this code.
'Feel free to update the code as per your need and also share with your friends.
'Download free codes from http://vbaa2z.blogspot.com
'Support our channel: youtube.com/vbaa2z
'Author: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

    If x = True Then
    With Application
        PriorCalcMode = Application.Calculation
            .ScreenUpdating = False
            .DisplayAlerts = False
            .EnableEvents = False
            .Cursor = xlWait
            .Calculation = xlCalculationManual
    End With
    
    ElseIf x = False Then
    
    With Application
            .ScreenUpdating = True
            .DisplayAlerts = True
            .EnableEvents = True
            .StatusBar = False
            .Cursor = xlDefault
        .Calculation = PriorCalcMode
        End With
    End If

End Function
Private Sub CommandButton4_Click() ten hemen sonra
TurnOnSpeed True
ekleyiniz.

End Sub tan hemen önce
TurnOnSpeed False
ekyeniz.
 
Yeni bir module ekleyerek aşağıdaki kodları ekleyiniz.
Kod:
Refer to Usage Example on how to use the code.

Public PriorCalcMode As Variant

Public Function TurnOnSpeed(x As Boolean)

'-----------------------------
'Thanks for downloading the code.
'Please visit our channel for a quick explainer on how to use this code.
'Feel free to update the code as per your need and also share with your friends.
'Download free codes from http://vbaa2z.blogspot.com
'Support our channel: youtube.com/vbaa2z
'Author: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

    If x = True Then
    With Application
        PriorCalcMode = Application.Calculation
            .ScreenUpdating = False
            .DisplayAlerts = False
            .EnableEvents = False
            .Cursor = xlWait
            .Calculation = xlCalculationManual
    End With
   
    ElseIf x = False Then
   
    With Application
            .ScreenUpdating = True
            .DisplayAlerts = True
            .EnableEvents = True
            .StatusBar = False
            .Cursor = xlDefault
        .Calculation = PriorCalcMode
        End With
    End If

End Function
Private Sub CommandButton4_Click() ten hemen sonra
TurnOnSpeed True
ekleyiniz.

End Sub tan hemen önce
TurnOnSpeed False
ekyeniz.
Çok teşekkür ederim Murat Bey 1 saniye bile sürmedi bu makroyu her yerde kullanabilir miyiz peki ?
 
Alternatif.
Kod:
Private Sub CommandButton4_Click()
sonsatir = Cells(Rows.Count, "a").End(xlUp).Row
Application.Calculation = xlCalculationManual
For i = 2 To sonsatir
Cells(i, 92) = Cells(i, 23) - Cells(i, 23) / (Cells(i, 91) + 1)
Next i
Application.Calculation = xlCalculationAutomatic
End Sub
 
Alternatif.
Kod:
Private Sub CommandButton4_Click()
sonsatir = Cells(Rows.Count, "a").End(xlUp).Row
Application.Calculation = xlCalculationManual
For i = 2 To sonsatir
Cells(i, 92) = Cells(i, 23) - Cells(i, 23) / (Cells(i, 91) + 1)
Next i
Application.Calculation = xlCalculationAutomatic
End Sub
Çok teşekkür ederim, sizlerin sayesinde her gün yeni şeyler öğreniyorum.
 
Geri
Üst