Hi Excel Experts,
I need some help creating VBA code that will accomplish a very repetitive task.
I have 2 sheets of data, I need to compare Sheet 1 to a specific range on Sheet 2 and where a value from that range on Sheet 2 appears in the PIO String (column 3) it needs to be removed from the string.
On sheet 2 there are 3 rows of headers that denote the series, code and description, these are for reference only and should not be checked against.
The challenge I have is Columns 1 and 2 need to be used as a reference for which list of values to check against on sheet 2. Column 2 is always 6 characters in length but the comparison only needs to be done against the first 4 characters since that is the layout on Sheet 2
Sheet 1
[TABLE="width: 500"]
<tbody>[TR]
[TD]Series[/TD]
[TD]PIO[/TD]
[TD]PIO STRING[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]4Runner[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1000[/TD]
[TD]CY2000 FP5000 MC2000 PF1000 RB5220 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tacoma 4X2[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1110[/TD]
[TD]CY2000 FP5000 MR1000 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tundra 4x2[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1500[/TD]
[TD]BS1000 CY2000 FP5000 LL1000 MR1000 PF1000 RB1100 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Camry[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1020[/TD]
[TD]CY2000 FP5010 MC1000 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD]
<tbody>
</tbody>[/TD]
[TD]XX2000[/TD]
[TD]FP4000 MR1000 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tacoma 4X4[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX2000[/TD]
[TD]FP5000 JB2300 MR1000 UF60[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tundra 4x4[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1300[/TD]
[TD]BS1000 BU1000 FP5000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]4Runner[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1000[/TD]
[TD]FP4000 MC2010 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Camry[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1020[/TD]
[TD]FP4010 MC1000 UF60 XY9000[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2: The sheet is 12 columns wide and up to 46 rows long.
[TABLE="width: 500"]
<tbody>[TR]
[TD]4Runner[/TD]
[TD]Tundra[/TD]
[/TR]
[TR]
[TD]XX10[/TD]
[TD]XX15[/TD]
[/TR]
[TR]
[TD]Wheel Package[/TD]
[TD]Wheel Package[/TD]
[/TR]
[TR]
[TD]AC1000[/TD]
[TD]AA2800[/TD]
[/TR]
[TR]
[TD]AJ1700[/TD]
[TD]AC1000[/TD]
[/TR]
[TR]
[TD]BG2000[/TD]
[TD]RB1100[/TD]
[/TR]
[TR]
[TD]RB5220[/TD]
[TD]ET1100[/TD]
[/TR]
[TR]
[TD]SBXP10[/TD]
[TD]AL6000[/TD]
[/TR]
</tbody>[/TABLE]
In this example, Row 2 on Sheet 1 would be compared to Column 1 on Sheet 2 because they share the same series and first 4 characters of the PIO code. The result would be that Row 2 needs to be altered because RB5220 is present in the corresponding list on Sheet 2 the same goes for Row 4 for RB1100.
The formatting of the end result is sensitive also, Sheet 1 Column 3 needs to maintain a single space between each item.
I hope this comes across clearly, I am happy to clarify further.
As always, thank you in advance for your help.
I need some help creating VBA code that will accomplish a very repetitive task.
I have 2 sheets of data, I need to compare Sheet 1 to a specific range on Sheet 2 and where a value from that range on Sheet 2 appears in the PIO String (column 3) it needs to be removed from the string.
On sheet 2 there are 3 rows of headers that denote the series, code and description, these are for reference only and should not be checked against.
The challenge I have is Columns 1 and 2 need to be used as a reference for which list of values to check against on sheet 2. Column 2 is always 6 characters in length but the comparison only needs to be done against the first 4 characters since that is the layout on Sheet 2
Sheet 1
[TABLE="width: 500"]
<tbody>[TR]
[TD]Series[/TD]
[TD]PIO[/TD]
[TD]PIO STRING[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]4Runner[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1000[/TD]
[TD]CY2000 FP5000 MC2000 PF1000 RB5220 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tacoma 4X2[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1110[/TD]
[TD]CY2000 FP5000 MR1000 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tundra 4x2[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1500[/TD]
[TD]BS1000 CY2000 FP5000 LL1000 MR1000 PF1000 RB1100 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Camry[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1020[/TD]
[TD]CY2000 FP5010 MC1000 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD]
Tacoma 4X4 |
<tbody>
</tbody>
[TD]XX2000[/TD]
[TD]FP4000 MR1000 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tacoma 4X4[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX2000[/TD]
[TD]FP5000 JB2300 MR1000 UF60[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Tundra 4x4[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1300[/TD]
[TD]BS1000 BU1000 FP5000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]4Runner[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1000[/TD]
[TD]FP4000 MC2010 PF1000 UF60 XY9000[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Camry[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]XX1020[/TD]
[TD]FP4010 MC1000 UF60 XY9000[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2: The sheet is 12 columns wide and up to 46 rows long.
[TABLE="width: 500"]
<tbody>[TR]
[TD]4Runner[/TD]
[TD]Tundra[/TD]
[/TR]
[TR]
[TD]XX10[/TD]
[TD]XX15[/TD]
[/TR]
[TR]
[TD]Wheel Package[/TD]
[TD]Wheel Package[/TD]
[/TR]
[TR]
[TD]AC1000[/TD]
[TD]AA2800[/TD]
[/TR]
[TR]
[TD]AJ1700[/TD]
[TD]AC1000[/TD]
[/TR]
[TR]
[TD]BG2000[/TD]
[TD]RB1100[/TD]
[/TR]
[TR]
[TD]RB5220[/TD]
[TD]ET1100[/TD]
[/TR]
[TR]
[TD]SBXP10[/TD]
[TD]AL6000[/TD]
[/TR]
</tbody>[/TABLE]
In this example, Row 2 on Sheet 1 would be compared to Column 1 on Sheet 2 because they share the same series and first 4 characters of the PIO code. The result would be that Row 2 needs to be altered because RB5220 is present in the corresponding list on Sheet 2 the same goes for Row 4 for RB1100.
The formatting of the end result is sensitive also, Sheet 1 Column 3 needs to maintain a single space between each item.
I hope this comes across clearly, I am happy to clarify further.
As always, thank you in advance for your help.