Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Lookup table

Posted on 2004-03-25
4
Medium Priority
?
524 Views
Last Modified: 2012-06-22
Please help (once again...!)
I need to retrieve an element from a cell block but cannot get it right.

I have the following on an EXCEL worksheet

V7      P7      W7      P4      L7
AES      ZZA      MMG      IVB      MMA
IID      ZZB      MMH      IVF      MMB
IIG      ZZC      MMI      IVI      MMC
IIJ            MMJ      IVM      MMD
IIK            MMK      IVO      MME
IIN            MML      IVR      MMF
IIS            MMM      IVS      
IIT            MMN      IVW      
IIU            MMO      IVX      
IIV            MMP      IVY      
IIW                  IVZ      
IIX                  NLE      
IIY                  NLF      
                  NLK      
                  NLN      
                  NLO      
                  NLP      
                  NLS      
                  NLT      
                  NLV      
                  NLW      
                  NLX      
                  NLY      
                  NLZ      
                  YGB      
                  YGE      
                        
                        
                        
                        
                        
The data being supplied is one of the values AES, IVX etc. etc. and what I want is the value at the top of the appropriarte column (ie one of P4, W7, P7 etc.)
How do I use the appropriate lookup and reference functions to extract the value at the top of the column, given the value supplied.
Note that the number of values in each column is not constant and that the values are not in sorted order, although this could be done if it makes the solution easier.

Big points available for the first person to get it right
0
Comment
Question by:GSD4ME
4 Comments
 
LVL 15

Expert Comment

by:SRigney
ID: 10680112
I don't know excel well enough to provide the solution, but I can give you a quick logic approach that you can try.

Find the item that you are looking for.  I would guess that Excel provides a find function that returns a cell.

When you know the cell that you are in then you need to look in the first row of the same colum to get it's value.

Of course what I'm saying may be what you already know.
0
 
LVL 5

Assisted Solution

by:g0rath
g0rath earned 1000 total points
ID: 10680562
Dim SearchRange as Excel.Range
Dim FoundCell as Excel.Range

Set SearchRange = ThisWorkbook.Worksheet("Sheet1").UsedRange
Set FoundCell = SearchRange.Find("Hello")

Then you can do stuff like

Set FoundCell = SearchRange.FindNext

etc etc...

0
 
LVL 1

Accepted Solution

by:
MADisonMAN earned 1000 total points
ID: 10681833
In addition to g0rath you can do like that. Put this code in a macro and call. You need to call everytime for each supplied value. Hope this helps you more.

Dim SearchRange As Excel.Range
Dim FoundCell As Excel.Range
Dim SuppliedValue As String

SuppliedValue = InputBox("Enter Cell Value to Find")
Set SearchRange = ThisWorkbook.Worksheets("Sheet1").UsedRange
Set FoundCell = SearchRange.Find(SuppliedValue)


'MsgBox FoundCell.Address
'MsgBox FoundCell.Column
MsgBox FoundCell.EntireColumn.Cells(1, 1).Value

FoundCell.EntireColumn.Cells(1, 1).Activate
0
 

Author Comment

by:GSD4ME
ID: 10688981
Thanks to the pair of you for the answer - exactly what I wanted.
Points have been split evenly
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question