VBA code to loop through 2 worksheets and find the matching Column title

Nite0wls

New Member
Joined
May 21, 2014
Messages
33
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Dear Experts,

As newbie I am seeking your help in resolving my challenge for the below task.

I have two tabs in Excel 2010 version.

Tab 1 = "Tel Nr table"
Tab 2 = "IVR Table"

Tel Nr Table
[TABLE="class: cms_table_outer_border, width: 1237"]
<tbody>[TR]
[TD]Note[/TD]
[TD]IP ROW[/TD]
[TD]DNIS[/TD]
[TD]Country[/TD]
[TD]Languages[/TD]
[TD]Site[/TD]
[TD]IVR[/TD]
[TD]TEST[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]848[/TD]
[TD]5600:crash:[/TD]
[TD]Australia[/TD]
[TD]en-AU[/TD]
[TD]APAC[/TD]
[TD]APAC Main[/TD]
[TD] APAC Main[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]849[/TD]
[TD]5601:crash:[/TD]
[TD]Australia[/TD]
[TD]en-AU[/TD]
[TD]APAC[/TD]
[TD]APAC Main[/TD]
[TD] APAC Main[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]850[/TD]
[TD]5602[/TD]
[TD]Australia[/TD]
[TD]en-AU[/TD]
[TD]APAC[/TD]
[TD] APAC MR Direct Dial[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]851[/TD]
[TD]5603[/TD]
[TD]Australia[/TD]
[TD]en-AU[/TD]
[TD]APAC[/TD]
[TD]APAC Main[/TD]
[TD] APAC Main[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]852[/TD]
[TD]5604[/TD]
[TD]Australia[/TD]
[TD]en-AU[/TD]
[TD]APAC[/TD]
[TD]APAC Main[/TD]
[TD] APAC Main[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]853[/TD]
[TD]5605[/TD]
[TD]Australia[/TD]
[TD]en-AU[/TD]
[TD]APAC[/TD]
[TD]APAC Main[/TD]
[TD] APAC Main[/TD]
[/TR]
</tbody>[/TABLE]

IVR Table
[TABLE="class: cms_table_outer_border, width: 696"]
<tbody>[TR]
[TD]APAC DR[/TD]
[TD]APAC DR Direct Dial[/TD]
[TD]APAC DR Transfer[/TD]
[TD]APAC Main[/TD]
[TD]APAC MR[/TD]
[TD]APAC MR Direct Dial[/TD]
[/TR]
[TR]
[TD]610012[/TD]
[TD]202[/TD]
[TD]610002[/TD]
[TD]5600:crash:[/TD]
[TD]610013[/TD]
[TD]203[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5601:crash:[/TD]
[TD][/TD]
[TD]57641202[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5603[/TD]
[TD][/TD]
[TD]57641211[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5604[/TD]
[TD][/TD]
[TD]57641218[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5605[/TD]
[TD][/TD]
[TD]57641241[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5607[/TD]
[TD][/TD]
[TD]5602[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5610[/TD]
[TD][/TD]
[TD]5608[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5611[/TD]
[TD][/TD]
[TD]5613[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5614[/TD]
[TD][/TD]
[TD]5627[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5615[/TD]
[TD][/TD]
[TD]5630[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5616[/TD]
[TD][/TD]
[TD]5635[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5617[/TD]
[TD][/TD]
[TD]5641[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5618[/TD]
[TD][/TD]
[TD]5646[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5620[/TD]
[TD][/TD]
[TD]5657[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5621[/TD]
[TD][/TD]
[TD]57641245[/TD]
[/TR]
</tbody>[/TABLE]

The task at hand is to extract the title name from each the column on the IVR Table worksheet to the Test column on the Tel nr Table when the numbers on the both worksheets are matching. In each worksheet the number is unique, however not all numbers are nessecarely in the IVR table.

Background is that the IVR Table data is extracted from a system, while the values in the IVR column in the Tel nr Table was manualy added. The IVR has been changed many times and the manual values haven't been updated and I need to know which are out of sync and to correct those that are incorrect.

The IVR Table has 150 different column names across with underneeth the corresponding numbers to these names.
The numbers under the columns can go up to 600 numbers deep, might extend (more then 150 titles and 600 nrs) or shrink (less than 150 titles and 600 nrs)

Hence what I try is to match each number column C (DNIS) from the Tel Nr Table with the corresponding number in the IVR Table, once found go to the top column and take the column label and put that label in the Tel Nr Table Test (column H) for the row I found the Tel Nr on. Since I don't know what nr matches with what IVR Column it is a bit complicated. It also might be that another IVR is added or one is removed, for which I have to transfer the numbers, so I might need to compare in future again.
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Similar threads

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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