+ Reply to Thread
Results 1 to 2 of 2

Degresive depreciation automation code not working!

Hybrid View

  1. #1
    Registered User
    Join Date
    03-14-2011
    Location
    Bucharest
    MS-Off Ver
    Excel 2003
    Posts
    1

    Post Degresive depreciation automation code not working!

    Hi there !
    I recently had some problems with an excel macro which calculates the digressive depreciation of an asset.It might be a problem with the repetitive structures. If you could help me in this problem i would be very grateful ! Thank you!

    Here is the VBA Code behind the macro:

    Private Sub CommandButton2_Click()
    Dim i As Variant
    Dim j As Variant
    Dim s As Variant
    Dim t As Variant
    Dim g As Variant
    Dim n, o, p As Variant
    Dim q As Date
    Dim f As Variant
    Dim AN, N0 As Variant
    Dim w, w2 As Variant
    Dim N1, N2 As Variant
    Dim h, k, S40 As Variant
    Dim S01 As String
    Dim m, tt As Variant
    Dim val02, zz, AS1, as2, zz2 As Variant
    Dim nn1, pp, pp02, val03 As Variant
    Dim iii, jj5 As Integer
    Dim rez, rest As Variant
    Dim Max22 As Variant
    Dim gg01, gg02, mm, ll, nr12, op1 As Variant
    Dim az, ttt As Integer
    Dim abc As Variant
    Dim jj As Integer
    
    t = 65
    i = 45
    w = 1
    Do Until i > t
    
        n = Sheets("AMORTIZARE").Cells(i, 3) 'val de intrare a activului
        m = Sheets("AMORTIZARE").Cells(i, 4) 'durata normala de functionare
        q = Sheets("AMORTIZARE").Cells(i, 5) 'cota anuala de amortizare
        o = Sheets("AMORTIZARE").Cells(i, 6) 'cota anuala de amortizare degresiva
        zz = n
        jj = 2
                      
                        Do Until (val02 * (o / 100) <= val02 / (m + 1) - jj) 'And (jj < m + 1)
                        Sheets("SA").Cells(i, jj) = zz * o / 100
                        val02 = zz - Sheets("SA").Cells(i, jj)
                        zz = val02
                        jj = jj + 1
                        az = m + 1 - jj
                        Loop
                      
                         abc = val02 * (o / 100)
    
                        For ttt = az To m + 1
                        Sheets("SA").Cells(i, ttt) = abc
                        Next
    i = i + 1
    Loop
      Max22 = 0
      Sheets("SA").Select
      Sheets("SA").Cells(44, 1) = "Nr crt \ An"
      Sheets("SA").Select
      For gg01 = 45 To 64
      mm = Sheets("AMORTIZARE").Cells(gg01, 4)
      If Max22 < mm Then
                 Max22 = mm
                 End If
       
      Next
      ll = 1
      For gg02 = 2 To Max22 + 1
      Sheets("SA").Cells(44, gg02) = ("An " & ll)
      ll = ll + 1
      Next
      nr12 = 1
      For op1 = 45 To 64
      If Sheets("AMORTIZARE").Cells(op1, 3) <> 0 Then
                              Sheets("SA").Cells(op1, 1) = nr12
                              nr12 = nr12 + 1
                              End If
      Next
    
    End Sub

    And here is a bunch of useful links for the method of calculation:
    http://www.assetaide.com/depreciation/calculation.html
    http://my.opera.com/BangNgo/blog/dep...-methods-in-ax
    Last edited by Alex Cociorva; 03-15-2011 at 04:26 AM. Reason: not conforming with rule 3 (code structures)

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Excel Code problem!! degressive depreciation vba code not working!!

    Welcome to the Forum. If you want our help please take the time to read & follow out Forum Rules

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Last edited by royUK; 03-14-2011 at 08:56 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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