#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Wrong code?

Hello,

Please can someone point out my error below.

Range("I22").Select
ActiveCell.FormulaR1C1 = "=if(" & ActiveCell.Offset(0, -1) &
"-1500)<0,0,RoundDown((" & ActiveCell.Offset(0, -1) & "-1500)/900,0)+1)"

Cheers

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Wrong code?



I think you just needed the underscore at the end of the first line.

ActiveCell.FormulaR1C1 = "=if(" & ActiveCell.Offset(0, -1) & _
"-1500)<0,0,RoundDown((" & ActiveCell.Offset(0, -1) & "-1500)/
900,0)+1)"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Wrong code?

If the cell to the left of the activecell contains 20000, this is what it
produces:

=if(20000-1500)<0,0,RoundDown((20000-1500)/900,0)+1)

so you see you are missing a Left paren before the first 20000

ActiveCell.FormulaR1C1 = "=if((" & ActiveCell.Offset(0, -1) &
"-1500)<0,0,RoundDown((" & ActiveCell.Offset(0, -1) & "-1500)/900,0)+1)"

--
Regards,
Tom Ogilvy


"GBH99" wrote:

Hello,

Please can someone point out my error below.

Range("I22").Select
ActiveCell.FormulaR1C1 = "=if(" & ActiveCell.Offset(0, -1) &
"-1500)<0,0,RoundDown((" & ActiveCell.Offset(0, -1) & "-1500)/900,0)+1)"

Cheers

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Wrong code?

Try

Sub OffsetActivecellformula()
ac = Range("i22").Address
Range(ac).Formula = "=ROUNDDOWN(OFFSET(" & ac & ",0,-1)" _
& "-IF(OFFSET(" & ac & ",0,-1)-1500<0,0,1500)/900,0)"
'formula below
'=ROUNDDOWN(OFFSET(L8,0,-1)-IF(OFFSET(L8,0,-1)-1500<0,0,1500)/900,0)
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"GBH99" wrote in message
...
Hello,

Please can someone point out my error below.

Range("I22").Select
ActiveCell.FormulaR1C1 = "=if(" & ActiveCell.Offset(0, -1) &
"-1500)<0,0,RoundDown((" & ActiveCell.Offset(0, -1) & "-1500)/900,0)+1)"

Cheers


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
Help with what is wrong with code OssieMac Excel Programming 1 March 28th 07 03:05 AM
Help with what is wrong with code Joel Excel Programming 0 March 28th 07 01:14 AM
Can someone tell me what is wrong with this code? Ant Excel Discussion (Misc queries) 8 November 14th 05 02:53 PM
What's wrong with this code, please? Jim Berglund Excel Programming 1 August 3rd 04 09:41 PM
What's wrong w/my code? nrage21[_54_] Excel Programming 5 July 28th 04 03:50 PM


All times are GMT +1. The time now is 10:34 PM.

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"