+ Reply to Thread
Results 1 to 2 of 2

Macro is running very low

  1. #1
    Registered User
    Join Date
    12-11-2020
    Location
    canada
    MS-Off Ver
    newer
    Posts
    1

    Macro is running very low

    Hi, I'm doing a work for school with vba and excel, but I have a problem. I think it's slow because one of my row need an other one to calculate. I don't know if there's a way to do that faster, because right now I have a delay of 10-15 secondes each time I change something.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    nbgele = Cells(4, 9)
    n = Cells(4, 3)
    interet = Cells(6, 3)
    nb = Cells(5, 9) * 12

    If Cells(8, 10) = "oui" Then
    Range("C11:C300").Clear
    Cells(8, 10) = ""
    End If


    For c = 12 To nb + 11
    solde = Cells(11, 10)
    t = Cells(11, 2)
    paiement = (solde * interet) / (1 - (1 + interet) ^ (t - n))
    Cells(c, 5) = paiement
    Next

    For i = nb + 12 To n + 11
    If Cells(i, 3) = "" Then
    solde = Cells(i - 1, 10)
    t = Cells(i - 1, 2)
    paiement = (solde * interet) / (1 - (1 + interet) ^ (t - n))
    Cells(i, 5) = paiement
    Else
    numeroLigne = i
    solde = Cells(numeroLigne - 1, 10)
    t = Cells(numeroLigne - 1, 2)
    paiement = (solde * interet) / (1 - (1 + interet) ^ (t - n))
    For a = 0 To nbgele - 1
    Cells(numeroLigne + a, 5) = paiement
    If (n - i) > nbgele Then
    Cells(numeroLigne + a, 3) = Cells(numeroLigne, 3)
    Else
    Cells(i, 3) = ""
    End If
    Next
    i = numeroLigne + nbgele - 1
    End If
    Next

    If Cells(3, 3) = 20 Then
    For j = 1 To 60
    Cells(251 + j, 5) = ""
    Next
    End If



    Application.EnableEvents = True

    End Sub

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro is running very low

    Administrative Note:

    Welcome to the forum.

    You have made a few basic mistakes with your coding that are easily rectified. However:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Last edited by mehmetcik; 12-11-2020 at 03:14 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel is hanging or freezing while running macro but macro still running.
    By Atik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2018, 03:48 AM
  2. [SOLVED] Event Driven Macros stop running after running a routine macro
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2017, 12:34 PM
  3. code works running in visual basic editor but not when running from Excel macro
    By smporco in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-06-2016, 05:44 PM
  4. [SOLVED] How to prevent worksheet code from running while Module Macro is running:
    By Chad Bateman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2015, 09:26 AM
  5. Replies: 5
    Last Post: 12-19-2014, 01:31 AM
  6. Macro to hide/unhide cells not running or running slow
    By mbp727 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2013, 04:22 PM
  7. Prevent functions from running while macro is running
    By palpha32 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-24-2009, 08:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1