Hello
@catae
Welcome to the MrExcel forum. Please accept my warmest greetings and sincere hope that all is well.
I think you missed column F.
If you have your data like this:
Dante Amor |
---|
|
---|
| A | B | C | D | E | F | G | H | I | J | K |
---|
1 | ID | Channel | Feeling | Vertical | Type | Post | Canal | Polaridad | Transacción | Tipo de mensaje | Tipo de post |
---|
2 | 1_1 | facebook | neutral | publicar | solicitud | | facebook | Negativo | arriendo | asesoría | memes |
---|
3 | 1_2 | comprar | facebook | neutral | solicitud | | IG | positivo | crédito | comentarios | tendencia |
---|
4 | 1_3 | comentarios | positivo | | | | Tik Tok | neutral | publicar | solicitud | blog |
---|
5 | 1_4 | blog | comentarios | facebook | positivo | | fac | | subasta | | educativo |
---|
6 | 1_5 | arriendo | facebook | neutral | solicitud | | | | subsidio | | free press |
---|
7 | 1_6 | comentarios | neutral | publicar | | | | | comprar | | |
---|
|
---|
The result will be like this:
Dante Amor |
---|
|
---|
| A | B | C | D | E | F | G | H | I | J | K |
---|
1 | ID | Channel | Feeling | Vertical | Type | Post | Canal | Polaridad | Transacción | Tipo de mensaje | Tipo de post |
---|
2 | 1_1 | facebook | neutral | publicar | solicitud | | facebook | Negativo | arriendo | asesoría | memes |
---|
3 | 1_2 | facebook | neutral | comprar | solicitud | | IG | positivo | crédito | comentarios | tendencia |
---|
4 | 1_3 | | positivo | | comentarios | | Tik Tok | neutral | publicar | solicitud | blog |
---|
5 | 1_4 | facebook | positivo | | comentarios | blog | fac | | subasta | | educativo |
---|
6 | 1_5 | facebook | neutral | arriendo | solicitud | | | | subsidio | | free press |
---|
7 | 1_6 | | neutral | publicar | comentarios | | | | comprar | | |
---|
|
---|
Test the following Macro:
VBA Code:
Sub categorize()
Dim rng1 As Range, rng2 As Range, f As Range
Dim a As Variant, b As Variant
Dim i As Long, j As Long, col As Long
Set rng1 = Range("B2:F" & Range("A" & Rows.Count).End(3).Row)
Set rng2 = Range("G:K")
a = rng1.Value
ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))
col = rng2.Cells(1).Column - 1
For i = 1 To UBound(a, 1)
For j = 1 To UBound(a, 2)
If a(i, j) <> "" Then
Set f = rng2.Find(a(i, j), , xlValues, xlWhole, , , False)
If Not f Is Nothing Then
b(i, f.Column - col) = a(i, j)
End If
End If
Next
Next
rng1.Value = b
End Sub
HOW TO INSTALL MACROs
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (
categorize) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
Note XL2BB:
For the future, it would help greatly if you could give us the sample data in a form that we can copy to test with,
rather that a picture.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here:
XL2BB Add-in
Note that there is also a "
Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
--------------
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
--------------