How to make Join in VisualBasic

T

Tony

Hello,
I have two sheets in excel that I want to join them by name.
is there any command that can I use like the join command in SQL ?
The first sheet contains the following data:
Name, Telephone, ID
The Second Sheet contain:
Name, Shift, Team.
each name appear only one time in each sheet or it may not appear in
the second sheet.

in SQL, the syntax is:
Select Name, Telephone, Shift
From Sheet1, Sheet2
Where Sheet1.name = Sheet2.name

How do I do that in visual Basic in Excel ?
Thanks.
 
D

dolivastro

Just out of curiosity, I have to ask something: When I see posts like
this, that want to go very deep into SQL, why is the project in EXCEL
at all? Shouldn't it be in Access?

Anyone?
Dom
 
B

Bob Phillips

Because Excel has a better (decent!) development environment, and you can
then use Excel functionality on the retrieved data. And plus, some sites
don't have Access.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
T

Tony

Hello,
I'm sorry that it took so long to answer...
first, Thanks for the help.
I'm getting a compiling problem when I run the macro that appears in
the link that you gave.
The error occours in the following line:
Dim rs As ADODB.Recordset

notice that I don't have Microsoft Access installed in the computer...
 
B

Bob Phillips

You need to set a reference to the ActiveX Data Objects Library.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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