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

Im assigning cell contents to variables;

Mid = Range("A9").Value
Nor = Range("C9").Value
Uni = Range("E9").Value

While this procedure is running I need to sort those three variables low to
high then run a series of nested if statements. I do not know how to sort
the variables assigning a ranking to be used in the nested ifs. Any advise
welcome€¦

Appreciatively,
Arturo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Variable Manipulation

Arturo,

How about this to put them into ascending order

Dim ary(1 To 3)
Dim temp

ary(1) = Range("A9").Value
ary(2) = Range("C9").Value
ary(3) = Range("E9").Value
If ary(1) ary(2) Then
temp = ary(2)
ary(2) = ary(1)
ary(1) = temp
End If
If ary(2) ary(3) Then
temp = ary(3)
ary(3) = ary(2)
ary(2) = temp
If ary(1) ary(2) Then
temp = ary(2)
ary(2) = ary(1)
ary(1) = temp
End If
End If

You can then use it's index as the rank

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Arturo" wrote in message
...
I'm assigning cell contents to variables;

Mid = Range("A9").Value
Nor = Range("C9").Value
Uni = Range("E9").Value

While this procedure is running I need to sort those three variables low

to
high then run a series of nested if statements. I do not know how to sort
the variables assigning a ranking to be used in the nested ifs. Any

advise
welcome.

Appreciatively,
Arturo



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Variable Manipulation

First of all do not use variable name Mid cause it conflicts with
function 'Mid'
use variable names iNor iMid iUni.
Then decide what will you do if two of the variables are equal or if all
three are equal.
Assuming that none will be equal you can use code like following.

If iNor iMid And iNor iUni Then
'your code to run if iNor is highest
End if

If iMid iNor And iMid iUni Then
'your code to run if iMid is highest
End if

If iUni iNor And iUni iMid Then
'your code to run if iUni is highest
End if

However you can reduce the number of statements, also run with other
conditions. If you can post exact conditions you want to satisfy, it
will help.

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Value manipulation Vic Excel Discussion (Misc queries) 3 April 3rd 09 03:18 PM
Data Manipulation. Wilson Excel Discussion (Misc queries) 0 August 13th 08 03:06 PM
Text manipulation paulinoluciano Excel Worksheet Functions 5 April 18th 06 01:24 AM
string manipulation banavas[_16_] Excel Programming 2 July 9th 04 07:55 AM
string manipulation Craig[_8_] Excel Programming 2 January 7th 04 05:00 AM


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