Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


--
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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"
wrote in message
news:T.De.Villiers.21tttb_1137581402.5197@excelfor um-nospam.com...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default 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"
wrote in message
news:T.De.Villiers.21tttb_1137581402.5197@excelfor um-nospam.com...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Time Error 1004 - Application-defined or object-defined error brent Excel Programming 2 October 3rd 05 05:23 PM
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error -[::::Shamran::::]- Excel Programming 7 June 7th 05 02:14 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM


All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"