Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding index place in list

Status
Not open for further replies.

Igwiz

Technical User
Jun 3, 2003
88
CA
Hi All,

I want to compare two cell values that will have words in them. Each word will have a number associated with it (in no particular alphabetical order) and the comparison will return a Boolean as to whether cell1 "value" > cell2 "value".

I was hoping I could set up an array-type thing and then use an index query like this:

Word-Order = ("Bob","Jim","Ed","Keith")
cell1 = "Bob"
cell2 = "Ed"
Index(Word-Order,cell2)>Index(Word-Order,cell1) = True

Is that the best way to do it? I know I could set up a table and do a find and offset but this method looks like it couple be more elegant.

Any ideas on the code required as I can;t find the relevant Index function on help.

Many thanks,

Ig
 
I'm quite not sure what you are trying to do, but if you just want to compare two cell values (number or text), you can use the EXACT() function directly in Excel, and you don't have to write code to compare the values.

Assuming the value you want to check is in A1 and the value that you are comparing it to is in B1, then write the following in C1:

=EXACT(A1,B1)

If you insist on using VBA code, then let me know.

I hope this helps!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Not what I'm looking for Mike. As an example, assume the order of the Word-List is height of the person from shortest to tallest. I need to run the function on the name but as I know the names are in the right order in the list, I want to compare their relative positions. Hope I'm making enough sense! So - Is Bob Shorter then Jim? would return TRUE because Bob is index position 1 and Jim is index position 2 within the Word-Order list.


Ig

ps. Apologies for the rather inane example!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top