Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Check difference

I have a sub that is called from a loop. It is supposed to check if the
difference between two numbers is greater than a predefined errror
tolarnance. However the difference between the two numbers shall only be
checked if neither of them are zero.

My problem is that no differences are deterected. My code is:

Dim dblLocalReturnDiff As Double
If rng4.Offset(l, 0) < 0 And rng3.Offset(l, 0) < 0 And rng4.Offset(l,
0) < rng3.Offset(l, 0) Then
dblLocalReturnDiff = rng4.Offset(l, 0) - rng3.Offset(l, 0)
If Abs(dblLocalReutrnDiff) dblErrorMarginal Then
MsgBox ("Local return skiljer sig åt mellan portföljen och
benchmark!" & vbCrLf & "Kolla upp vad detta kan bero på.")
Err.Raise 600
End If
End If

I supsect that the problem is to be found in the first IF statement. What I
want to say is that is neither one of the two values is zero and the two
values are not equal to one another then I want to continue the check. I do
not know how to write that so that it works. Please help me. Thanks very much!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Check difference

if you change
If Abs(dblLocalReutrnDiff) dblErrorMarginal Then

to

If Abs(dblLocalReturnDiff) dblErrorMarginal Then

so dblLocalReturnDiff is spelled correctly, it seems to work.

--
Regards,
Tom Ogilvy


"Arne Hegefors" wrote:

I have a sub that is called from a loop. It is supposed to check if the
difference between two numbers is greater than a predefined errror
tolarnance. However the difference between the two numbers shall only be
checked if neither of them are zero.

My problem is that no differences are deterected. My code is:

Dim dblLocalReturnDiff As Double
If rng4.Offset(l, 0) < 0 And rng3.Offset(l, 0) < 0 And rng4.Offset(l,
0) < rng3.Offset(l, 0) Then
dblLocalReturnDiff = rng4.Offset(l, 0) - rng3.Offset(l, 0)
If Abs(dblLocalReutrnDiff) dblErrorMarginal Then
MsgBox ("Local return skiljer sig åt mellan portföljen och
benchmark!" & vbCrLf & "Kolla upp vad detta kan bero på.")
Err.Raise 600
End If
End If

I supsect that the problem is to be found in the first IF statement. What I
want to say is that is neither one of the two values is zero and the two
values are not equal to one another then I want to continue the check. I do
not know how to write that so that it works. Please help me. Thanks very much!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Check difference

Tom Ogilvy wrote:

if you change
If Abs(dblLocalReutrnDiff) dblErrorMarginal Then

to

If Abs(dblLocalReturnDiff) dblErrorMarginal Then

so dblLocalReturnDiff is spelled correctly, it seems to work.

"Arne Hegefors" wrote:

I have a sub that is called from a loop. It is supposed to check if the
difference between two numbers is greater than a predefined errror
tolarnance. However the difference between the two numbers shall only be
checked if neither of them are zero.

My problem is that no differences are deterected. My code is:

Dim dblLocalReturnDiff As Double
If rng4.Offset(l, 0) < 0 And rng3.Offset(l, 0) < 0 And rng4.Offset(l,
0) < rng3.Offset(l, 0) Then
dblLocalReturnDiff = rng4.Offset(l, 0) - rng3.Offset(l, 0)
If Abs(dblLocalReutrnDiff) dblErrorMarginal Then
MsgBox ("Local return skiljer sig åt mellan portföljen och
benchmark!" & vbCrLf & "Kolla upp vad detta kan bero på.")
Err.Raise 600
End If
End If

I supsect that the problem is to be found in the first IF statement. What I
want to say is that is neither one of the two values is zero and the two
values are not equal to one another then I want to continue the check. I do
not know how to write that so that it works. Please help me. Thanks very much!


This looks to me like a strong case for "Option Explicit".
--

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
Copy and move check box (check boxes) with new cell link? Marty Excel Worksheet Functions 1 January 20th 10 07:43 PM
Increase size of a Forms Check Box (click on to enter check mark) 718Satoshi Excel Discussion (Misc queries) 0 August 17th 07 01:52 AM
Check if Conditional Format is True or False / Check cell Color Kevin McCartney Excel Worksheet Functions 5 June 29th 07 11:12 AM
Enable check box in protected sheet + group check boxes Dexxterr Excel Discussion (Misc queries) 4 August 2nd 06 12:00 PM
charting a difference of 2 columns' w/o adding a difference column Wab Charts and Charting in Excel 4 July 27th 05 02:37 AM


All times are GMT +1. The time now is 12:18 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"