LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
guy guy is offline
external usenet poster
 
Posts: 12
Default join/union tables by querytable

Can querytable allow inner/left/right join or union table?
i got error msg code "1004" at the last line "varQry5.Refresh"...
my excel workbook has 3 sheets: table1, table2 and combine1.
actually i need to compare the 2 tables (sheets "table1" and "table2") cell
by cell, by first mapping the concatenated field NAME&AGE...
could anyone pls advise...?
is there any better way to do in Excel?
Thank you very much!!

--------------------------------------------------------------------------------
Sub test111()

Dim varConn5 As String, varSql5 As String
Dim varQry5 As QueryTable

varConn5 = "ODBC;DefaultDir=C:\testing;driver={Microsoft Excel Driver
(*.xls)};DriverId=790;dbq=C:\testing\test_table.xl s"

varSql5 = "SELECT [table1$].[NAME&AGE] as T1_KEY, [table2$].[NAME&AGE] as
T2_KEY from [table1$] join [table2$] on
[table1$].[NAME&AGE]=[table2$].[NAME&AGE]"

Set varQry5 = Worksheets("combine1").QueryTables.Add(Connection: =varConn5,
Destination:=Worksheets("combine1").Range("a1"), Sql:=varSql5)

Worksheets("combine1").Range("A:IV").ClearContents

varQry5.BackgroundQuery = False
varQry5.Refresh

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Union or Join Sheets Jeff C Excel Discussion (Misc queries) 2 January 6th 09 06:16 PM
Join Excel Tables MT MEX Excel Discussion (Misc queries) 2 September 30th 08 10:08 PM
Join tables like inner join in Access ryanp Excel Discussion (Misc queries) 2 July 18th 08 03:35 PM
Merge/Join 2 Excel tables ryguy7272 Excel Programming 0 February 20th 07 06:20 PM
Union, intersection, join swchee[_2_] Excel Programming 1 June 28th 05 04:16 PM


All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"