From: David on 11 Apr 2010 12:58 Hello Group, I have a select case that is not working as I expected, Delta1ToSP = -3.38629648094637E-02 or -.0338: Select Case Delta1ToSP Case -0.02 To -0.05 ' This is where I expected the stop Stop Case -0.050001 To -0.1 Stop Case -0.10001 To -1 Stop Case 0.02 To 0.05 Stop Case 0.050001 To 0.1 Stop Case 0.10001 To 1 Stop Case Else Stop End Select What am I missing? Thanks, -- David
From: Rick Rothstein on 11 Apr 2010 13:18 You must put the smaller value on the left of the "To" keyword and the larger value on the right... Select Case Delta1ToSP Case -0.05 To -0.02 ' This is where I expected the stop Stop Case -0.050001 To -0.1 Stop Case -1 To -0.10001 Stop Case 0.02 To 0.05 Stop Case 0.050001 To 0.1 Stop Case 0.10001 To 1 Stop Case Else Stop End Select -- Rick (MVP - Excel) "David" <David(a)discussions.microsoft.com> wrote in message news:2FE79046-53B3-41F6-AAAB-133A0ED132FB(a)microsoft.com... > Hello Group, > > I have a select case that is not working as I expected, Delta1ToSP = > -3.38629648094637E-02 or -.0338: > > Select Case Delta1ToSP > Case -0.02 To -0.05 ' This is where I expected the stop > Stop > Case -0.050001 To -0.1 > Stop > Case -0.10001 To -1 > Stop > Case 0.02 To 0.05 > Stop > Case 0.050001 To 0.1 > Stop > Case 0.10001 To 1 > Stop > Case Else > Stop > End Select > > What am I missing? > > Thanks, > -- > David
From: Bernard Liengme on 11 Apr 2010 13:23 The statement: Case -0.02 To -0.05 needs to be coded as: Case -0.05 To -0.02 since -0.05 is smaller than -0.2 Don't be too hard on yourself - it is Sunday! best wishes -- Bernard Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme "David" <David(a)discussions.microsoft.com> wrote in message news:2FE79046-53B3-41F6-AAAB-133A0ED132FB(a)microsoft.com... > Hello Group, > > I have a select case that is not working as I expected, Delta1ToSP = > -3.38629648094637E-02 or -.0338: > > Select Case Delta1ToSP > Case -0.02 To -0.05 ' This is where I expected the stop > Stop > Case -0.050001 To -0.1 > Stop > Case -0.10001 To -1 > Stop > Case 0.02 To 0.05 > Stop > Case 0.050001 To 0.1 > Stop > Case 0.10001 To 1 > Stop > Case Else > Stop > End Select > > What am I missing? > > Thanks, > -- > David
From: JLatham on 11 Apr 2010 14:01 Reverse the arguments. The negative number has twisted your head (as they often do mine) and the Case ...To... needs small magnitude first: -.02 is LARGER in magnitude than -0.05. Case -0.05 To -0.02 will catch the value. "David" wrote: > Hello Group, > > I have a select case that is not working as I expected, Delta1ToSP = > -3.38629648094637E-02 or -.0338: > > Select Case Delta1ToSP > Case -0.02 To -0.05 ' This is where I expected the stop > Stop > Case -0.050001 To -0.1 > Stop > Case -0.10001 To -1 > Stop > Case 0.02 To 0.05 > Stop > Case 0.050001 To 0.1 > Stop > Case 0.10001 To 1 > Stop > Case Else > Stop > End Select > > What am I missing? > > Thanks, > -- > David
From: David on 11 Apr 2010 14:21 Thank you all. When I read through help, I don't think this was mentioned. "Don't be too hard on yourself - it is Sunday!" Space, the final frontier, lol. -- David "Rick Rothstein" wrote: > You must put the smaller value on the left of the "To" keyword and the > larger value on the right... > > Select Case Delta1ToSP > Case -0.05 To -0.02 ' This is where I expected the stop > Stop > Case -0.050001 To -0.1 > Stop > Case -1 To -0.10001 > Stop > Case 0.02 To 0.05 > Stop > Case 0.050001 To 0.1 > Stop > Case 0.10001 To 1 > Stop > Case Else > Stop > End Select > > -- > Rick (MVP - Excel) > > > > "David" <David(a)discussions.microsoft.com> wrote in message > news:2FE79046-53B3-41F6-AAAB-133A0ED132FB(a)microsoft.com... > > Hello Group, > > > > I have a select case that is not working as I expected, Delta1ToSP = > > -3.38629648094637E-02 or -.0338: > > > > Select Case Delta1ToSP > > Case -0.02 To -0.05 ' This is where I expected the stop > > Stop > > Case -0.050001 To -0.1 > > Stop > > Case -0.10001 To -1 > > Stop > > Case 0.02 To 0.05 > > Stop > > Case 0.050001 To 0.1 > > Stop > > Case 0.10001 To 1 > > Stop > > Case Else > > Stop > > End Select > > > > What am I missing? > > > > Thanks, > > -- > > David > > . >
|
Next
|
Last
Pages: 1 2 Prev: IP address to Hostname in Excel Next: Compile error. Need Help with this UDF !!!!!!!!!!!!!!! |