+ Reply to Thread
Results 1 to 3 of 3

Application Defined Error

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-20-2005
    Posts
    173

    Application Defined Error

    the below is a macro to divide b5/b4, b7/b6 etc.
    Howevr if b4,b6etc. are zero the formula should give zero,
    below isnt quite working, any help is much app.


    Sub cc()
    i = 5
    Do Until i = 15
    If Cells(1 - 1, 2) = 0 Then
    Cells(i, 3) = 0
    Else
    Cells(i, 3) = Cells(i, 2) / Cells(i - 1, 2)
    End If
    i = i + 2
    Loop

    End Sub

  2. #2
    Norman Jones
    Guest

    Re: Application Defined Error

    Hi T,

    Try changing:

    > If Cells(1 - 1, 2) = 0 Then


    to

    If Cells(i - 1, 2) = 0 Then


    ---
    Regards,
    Norman



    "T De Villiers" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > the below is a macro to divide b5/b4, b7/b6 etc.
    > Howevr if b4,b6etc. are zero the formula should give zero,
    > below isnt quite working, any help is much app.
    >
    >
    > Sub cc()
    > i = 5
    > Do Until i = 15
    > If Cells(1 - 1, 2) = 0 Then
    > Cells(i, 3) = 0
    > Else
    > Cells(i, 3) = Cells(i, 2) / Cells(i - 1, 2)
    > End If
    > i = i + 2
    > Loop
    >
    > End Sub
    >
    >
    > --
    > T De Villiers
    > ------------------------------------------------------------------------
    > T De Villiers's Profile:
    > http://www.excelforum.com/member.php...o&userid=26479
    > View this thread: http://www.excelforum.com/showthread...hreadid=502401
    >




  3. #3
    Bernard Liengme
    Guest

    Re: Application Defined Error

    You macro works for me when I correct the typo in
    FROM If Cells(1 - 1, 2) = 0 Then
    TO If Cells(i - 1, 2) = 0 Then

    That's why I never use i (upper or lower) or l (l for leather) as variables
    I started out with FORTRAN and everything was caps; these letters and 1 are
    hard to distinguish,
    --
    Bernard V Liengme
    www.stfx.ca/people/bliengme
    remove caps from email

    "T De Villiers" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > the below is a macro to divide b5/b4, b7/b6 etc.
    > Howevr if b4,b6etc. are zero the formula should give zero,
    > below isnt quite working, any help is much app.
    >
    >
    > Sub cc()
    > i = 5
    > Do Until i = 15
    > If Cells(1 - 1, 2) = 0 Then
    > Cells(i, 3) = 0
    > Else
    > Cells(i, 3) = Cells(i, 2) / Cells(i - 1, 2)
    > End If
    > i = i + 2
    > Loop
    >
    > End Sub
    >
    >
    > --
    > T De Villiers
    > ------------------------------------------------------------------------
    > T De Villiers's Profile:
    > http://www.excelforum.com/member.php...o&userid=26479
    > View this thread: http://www.excelforum.com/showthread...hreadid=502401
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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