Excel function "Join"

I need to combine rows from two Excel tables into one long row based on the identifier column in each of the sheets. In fact, I want to perform SQL JOIN equivalence on two sheets to create a combined worksheet.

I can get the Range object for the row in the first sheet, and then use the ID column to get the Range object for the corresponding row in the second sheet. Now I need to combine them.

I know the Merge and Union VBA methods, but I don’t think they do what I need.

How to combine these two range objects?

for example: sheet 1 line: a, b, c sheet 2 lines: d, e, f

combo string: a, b, c, d, e, f

+3
source share
4

d 1, vlookup 2, . e f?

+3

Robin Day Match() , Index() . , . 1:1. :

=MATCH(RowID, OtherTable, 0)

=INDEX(OtherTable, MATCH(), ColumnPosition)

+1

2 , , SQL- adodb.

dim cnn As ADODB.Connection
dim rst As ADODB.Recordset
strProv = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
                    SourceFile & ";Extended Properties=Excel 8.0;"
cnn.Open strProv
Set rst = New ADODB.Recordset
strSql = "select * from [Sheet1$]"
rst.Open strSql, cnn
rngDestRange.CopyFromRecordset rst

, . 100%, , .

0
source

Just look at the function VLOOKUPas a final argument - FALSE. He does exactly what you want.

0
source

Source: https://habr.com/ru/post/1715087/


All Articles