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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VLookUp or something else?

Status
Not open for further replies.

JICDB

Technical User
Apr 7, 2004
15
0
0
US
I'm using Excel Visual Basis 6.3 and am NOT a programmer. What I have is a 2 worksheet file (I can put it on one if it works better). One sheet contains exported information from a database and contains 6 different columns. In each cell of the second worksheet I need to do the following:

In English: Search on this worksheet "Fares 2005" in this named range "FullFare" and if a record contains "East Division" in column G, and "1" in column c, and "521" in column A, return the number in D3

Vlookup may not be the way to go but I'm not sure how to do it in VB. I need to know the best way to do it in Excel and if is a Vlookup table how do I match 3 columns to return exactly what I'm looking for. If not what other way can I get the return I am looking for.

 
I assume that you mean if a single row within the range has these values for columns A, C, and G ?
 
First off... This is the standalone VB forum...

Excel uses a version of VB called VBA (Visual Basic for Aplications)

For future reference, there is actually a forum for these type of questions here: forum707

If have have no experience in programming, you might be interested in recording macros...

basically, you select: Tools>Macro>Record New Macro from the menu...

Then, in excel, preform the task that you want to automate manually...

When done, press the stop button that appears to stop recording...

Save the macro if it prompts you.

You can then run the macro by pressing the Play button (if you have the Macro Toolbar visible) or select: Tools>Macro>Macros... Alt+F8
And select the Macro to run...

You can also press Alt+F11 to go to the VBA editor and modify the Macro... If you have questions at that point, you might post them in the VBA forum, for best results...

You can, post them here if you would like, but you might get better/faster results in that forum, plus it might help someone else with the same problem...

Here is an example of a recorded Find operation:
Code:
    Cells.Find(What:="321", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate

You can then use the ActiveCell, or Selection to access what it found...

You can also just go down the column and check each value by using Cells(row, col)...
Range("A1") is the same as Cells(1, 1)

something like:
Code:
Row = 1
Col = 1
Do While Cells(Row, Col) <> ""
  If Cells(Row, Col) = "Test Value" Then
    'Found A Match...
    Exit Do
  End If
Loop

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Thanks. I'll try the other forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top