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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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