Concatenate different columns with delimiter

Dani_LobP

Board Regular
Joined
Aug 16, 2019
Messages
126
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I am trying to concatenate different columns from 2 sheets, which are in different order one to each other.

This would be the columns i need from the Auto sheet, and their counter from Manual sheet:

AutoManual
ColumnColumn
QAB
ST
TU
UAN
VV
WAQ
XAT
YW
ZZ
AAAA
ABAH
ACAD
ADAI
AEAU
AFAV
AGAW
AIBG
AJAG
AKAE
ALAF
ARBN
ASBO
ATBP
AUBQ

<tbody>
</tbody>

As you can see, its a bit messy but so far i managed to get this, althou is not really working as expected:

Code:
ActiveCell = Join(Application.Index(Range("Q2:AU2").Value, 1, 0), "|")  <- this one works, but i don't need some columns between that range

Ideally i'd like this one below:
Code:
ActiveCell = Join(Application.Index(Range("Q2,S2:AG2,AI2:AL2,AR2:AU2").Value, 1, 0), "|") <- but for some reason is not working, i guess i do wrong the range..


And for the other sheet, i guess this is what should look like, but as before, is not working the range.
Code:
ActiveCell = Join(Application.Index(Range("AB2, T2, U2, AN2, V2, AQ2, AT2, W2, Z2, AA2, AH2, AD2, AI2, AU2, AV2, AW2, BG2, AG2, AE2, AF2, BN2, BO2, BP2, BQ2").Value, 1, 0), "|")


i also tried this, but doesn't really work as expected either:
Code:
ActiveCell = _   
 "=CONCATENATE(Q2,""|"", S2,""|"", T2,""|"", U2,""|"", V2,""|"", WQ2,""|"", X2,""|"", Y2,""|"", Z2,""|"", AA2,""|"", AB2,""|"", AC2,""|"", AD2,""|"", AE2,""|"", AF2,""|"", AG2,""|"", AI2,""|"", AJ2,""|"", AK2,""|"", AL2,""|"", AR2,""|"", AS2,""|"", AT2,""|"", AU2)"

Eventually the idea is have both concatenated rows pasted on a new sheet so i can compare both sheets with vlook up to be sure both sheets have same data.

This is connected to this query i did some days ago: https://www.mrexcel.com/forum/excel-questions/1109017-vlookup-loop.html?highlight=vlookup+loop

Hope someone can help, thanks in advance! :)
 
nice, thanks for the info :) i guess i can apply that with sheets trick more often and save time.
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
So i checked this,
both formulas, work, when columns in order it is crazy fast, i guess ill have to work that one out since is what i like most.
but for this to work i will need to add some ascending filter that is applied to both columns. the way i had to do it now for test is manually and is what i try to avoid.

and also,
when using this formula:
Code:
[COLOR=#333333] .Formula = "=--(LOOKUP(B2,A$2:A$" & lastrow & ")=B2)"[/COLOR]
this next line won't work, will show VALUE? error for some reason.
Code:
.[COLOR=#333333]Range("C1").Value = Evaluate("SUM(C2:C" & lastrow & ")")[/COLOR]

And when autofilter, is Criteria1:=1 meaning to remove blanks?

In the end what i need is those rows that are not matching, thats why i tagged matches as 0 and no matches as 1, so the sum would tell me if there is any, and with filter just display rows that didnt matched.
 
Upvote 0
The first problem should be an easy fix, changing the formula line to
Code:
.Formula = "=--(IFERROR(LOOKUP(B2,A$2:A$" & lastrow & ")=B2,0))"
should resolve the #VALUE! error in the sum line.

Also, the filter criteria should be 0, not 1. There are no blanks, just 1 if the 2 columns match or 0 if they don't.

The sort doesn't need to remain in place, the code writes the actual 1 / 0 values in the cells in place of the formulas, so if you need to go back to the original order after running the code it will not mess things up.
 
Last edited:
Upvote 0
Yes, that solves the issue, thanks!

i just noticed that when checking both concatenated cells, it will give error (so placing a 0) on some even if they are match.

Is it because is too long the information inside the cell?
 
Upvote 0
Is it because is too long the information inside the cell?
Quite possibly. The other thing to consider is the decimal precision of any numbers, in such cases you would be comparing the actual value, not the rounded value that is shown in the cell. Times and / or dates can also be problematic.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top