VLookup (Find & Retrieve) Problem

G

Gr8ful4Uall

I'd like to thank everyone for their help. I've been lurking for some time
and always found the answers I needed. I'm sure the solution to my latest
problem is on the board somewhere, but I can't locate it. So I'll ask..

In Excel 2003, what I'd like to do is allow the user to click on a cell to
display a code listing. The list contains the code (1-3 alphanumeric chars)
usually combined with a brief description (1-3 words) (which comes from 2
columns on a separate Worksheet within the same Workbook). Depending on what
type of code is displayed, there may also be an explanation to be displayed
(no more than 30 words). As the user maneuvers through the code listing, the
explanation changes to reflect the code with the focus. At any time, the user
can select the desired code. Once selected, the 1-3 char code is
automatically inserted into the cell that was used to display the code
listing.

Based solely on all the help on the board (and a ginormous amount of
determination), everything works except the following...1) if the user clicks
on any area of the textbox other than the 1-3 char code (i.e. the code
description), an error results, 2) the results of VLookup for the explanation
is one row below the selected associated code chars (i.e. if the user clicks
"P - Pneumatic", VLookup returns "Quarantined means that all ...").

Here is the code I'm using for VLookup...
Private Sub txtInstructions_MouseDown(ByVal Button As Integer, ByVal Shift
As Integer, ByVal X As Single, ByVal Y As Single)

Dim vClarText As Variant
'Selects only the code to lookup.
vClarText = Left(frmInstructions.txtInstructions.SelText, 1)
'Retrieves the code's clarification text and puts it in the clarification
textbox.
frmInstructions.txtClarification.Text = Application.VLookup(vClarText, _
Sheet4.Range("A2:D16"), 4, True)
DoEvents
Me.Repaint
DoEvents
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top