LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple constraint problem...


Hi guys

Hope you can help with a quick query - think I've missed somethin
basic cos I've been working on this all week!

I have a column of numbers with a rank (A to X) associated with each
let's say

col A col B
1.2 A
1.1 B
1.0 C
0.9 D
...

and I have a variable, called 'checkcase', which can be any number lik
1.093. What I'd like to do is have the code run down the list in colum
A, and select the row (and hence rank) that contains the number closes
to the variable (1.1, corresponding to B in this case. In addition, i
the number is outside the range of ranks, I want it to do somethin
different.

My attempt at the code is:


Sheets("Sheet1").Range("A1").Activate

If checkcase 1.2

' Say the value is too high for the ranking system

Else If checkcase < -1.2

' Say the value is too low for the ranking system

Else

Do While ((ActiveCell.Value - checkcase)^2 0.0025)
ActiveCell.Offset(1, 0).Activate
Loop

End If

Which works fine, until the variable lies exactly between 2 ranks, sa
1.15. It says "type mismatch". Presumably because the argument i
exactly 0.0025 in this case. I tried to solve it with a simple "="
but no luck; it must be getting confused. In this special case o
activecell.value - checkcase being 0.0025, ideally I'd like it t
select the lower rank.

Have a feeling this is a simple mistake / syntax issue - I'm a bit of
newbie to VBA.

Has anyone got any ideas on what is happening here, or if indeed ther
is a better way to handle this?

Thanks for your time!

Nei

--
Mcneiliu
-----------------------------------------------------------------------
Mcneilius's Profile: http://www.excelforum.com/member.php...fo&userid=1377
View this thread: http://www.excelforum.com/showthread.php?threadid=44802

 
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
Cells with time constraint Freshman Excel Worksheet Functions 4 March 10th 10 08:34 AM
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Adding a constraint. AhmtDY Excel Discussion (Misc queries) 2 May 6th 05 09:59 AM
cell value constraint Balder Excel Discussion (Misc queries) 2 April 18th 05 07:14 PM
solver constraint jojo Excel Worksheet Functions 0 February 17th 05 10:11 PM


All times are GMT +1. The time now is 01:18 PM.

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

About Us

"It's about Microsoft Excel"