find all values corresponding to each values

Deepk

Board Regular
Joined
Mar 21, 2018
Messages
105
Office Version
  1. 2016
Platform
  1. Windows
hi all,

I want vba code for following activity. Sample data is provided below.

Copy each value in 'Find value' column and find all in column 'For Topic 1'. Paste the find all values in the column 'Topic 1'. Repeat this activity for all column Topic 1 to 4.

[TABLE="class: grid, width: 600"]
<tbody>[TR]
[TD]Find Value[/TD]
[TD]Topic 1[/TD]
[TD]Topic 2[/TD]
[TD]Topic 3[/TD]
[TD]Topic 4[/TD]
[TD]For Topic 1[/TD]
[TD]For Topic 2[/TD]
[TD]For Topic 3[/TD]
[TD]For Topic 4[/TD]
[/TR]
[TR]
[TD]TA[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]TA|CA|PA|KA[/TD]
[TD]TA|CA|PA|KA[/TD]
[TD]CA|PA|KA[/TD]
[TD]PA|KA[/TD]
[/TR]
[TR]
[TD]PA[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]CA|PA|KA[/TD]
[TD]CA|PA|KA[/TD]
[TD]KA[/TD]
[TD]CA|PA|KA[/TD]
[/TR]
[TR]
[TD]CA[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]PA|KA[/TD]
[TD]CA|PA|KA[/TD]
[TD]PA|KA[/TD]
[TD]PA|KA[/TD]
[/TR]
[TR]
[TD]KA[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]KA[/TD]
[TD]KA[/TD]
[TD]KA[/TD]
[TD]KA[/TD]
[/TR]
</tbody>[/TABLE]

The final data should appear like the table below.

Please help me with the code. Thank you.
[TABLE="class: grid, width: 600"]
<tbody>[TR]
[TD]Find Value[/TD]
[TD]Topic 1[/TD]
[TD]Topic 2[/TD]
[TD]Topic 3[/TD]
[TD]Topic 4[/TD]
[TD]For Topic 1[/TD]
[TD]For Topic 2[/TD]
[TD]For Topic 3[/TD]
[TD]For Topic 4[/TD]
[/TR]
[TR]
[TD]TA[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]TA|CA|PA|KA[/TD]
[TD]TA|CA|PA|TA[/TD]
[TD]CA|PA|KA[/TD]
[TD]PA|KA[/TD]
[/TR]
[TR]
[TD]PA[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]CA|PA|KA[/TD]
[TD]CA|PA|KA|TA[/TD]
[TD]KA[/TD]
[TD]CA|PA|KA[/TD]
[/TR]
[TR]
[TD]CA[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]PA|KA[/TD]
[TD]CA|PA|KA[/TD]
[TD]PA|KA[/TD]
[TD]PA|KA[/TD]
[/TR]
[TR]
[TD]KA[/TD]
[TD]4[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]KA[/TD]
[TD]KA[/TD]
[TD]KA[/TD]
[TD]KA

[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
If you need VBA, this is a non-looping approach
Code:
Sub test()
    With Sheet1.Range("A:A")
        With Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp))
            With .Offset(0, 1).Resize(, 4)
                .FormulaR1C1 = "=COUNTIF(C[4], ""*"" & RC1 & ""*"")"
                .Value = .Value
            End With
        End With
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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