delete and put the matched item into adjacent cell

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
470
Office Version
  1. 2019
hello
I want matching the items in column B with the items in column H if the items are matched with column B then should put each matched item next to adjacent matched item in column A and delete the others not matched in the same column H .


DL .xlsm
ABCDEFGH
1SrDescriptionQTYLIST
21BS 185/70R13 EP150 INDO184BS 195R14C R623 THI
32BS 185R14C R624 INDO16BS 195R14C 613V JAP
43BS 175/65R14 B250 THI50BS 195R14C R660 TR
54BS 175/65R14 B250 INDO30BS 195/70R14 150 EZ THI
65BS 175/70R14 EP150 THI25BS 205R14C 613V JAP
76BS 165 R13C R624 INDO50BS 205R14C R624 INDO
88BS 165 R13C R624 INDO46BS 215R14C R624 INDO
99BS 175/70R13 B250 INDO1BS 185/65R15 B250 JAP
10BS 185/65R15 T005 INDO
11BS 185/65R15 T01 JAP
12BS 175/65R14 B250 INDO
13BS 175/70R14 EP150 THI
14BS 165 R13C R624 INDO
15BS 185R14C R624 INDO
16BS 175/65R14 B250 THI
17BS 165 R13C R624 INDO
18BS 175/70R13 B250 INDO
19BS 185/70R13 EP150 INDO
20BS 185/70R13 EP150 INDO
purchase


result in column H
DL .xlsm
ABCDEFGH
1SrDescriptionQTYITEMLIST
21BS 185/70R13 EP150 INDO1841BS 185/70R13 EP150 INDO
32BS 185R14C R624 INDO162BS 185R14C R624 INDO
43BS 175/65R14 B250 THI503BS 175/65R14 B250 THI
54BS 175/65R14 B250 INDO304BS 175/65R14 B250 INDO
65BS 175/70R14 EP150 THI255BS 175/70R14 EP150 THI
76BS 165 R13C R624 INDO506BS 165 R13C R624 INDO
87BS 175/70R13 B250 INDO87BS 185/70R13 EP150 INDO
98BS 165 R13C R624 INDO468BS 165 R13C R624 INDO
109BS 175/70R13 B250 INDO19BS 175/70R13 B250 INDO
11
purchase
my list about 1000 items .
 
Last edited:
again my apologies !!👃
I was hurry up
  • Why is cell A4 = 2 when in the original data cell A4 = 3
yes you're right should be 3 not to
  • Why is cell G4 = 3 when the original data has 2 for BS 185R14C R624 INDO?
because in post #9 add new items if you put in 2 then will not match for adjacent cell in B2 , in this case should leave the cell and keep empty as in picture
  • In cell H9, where did the BS 165 R13C R624 THI come from? I can't see that value anywhere in H2:H20 of the original data.
what do you mean ? based on post#9 is existed in H19 as in pic 1
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
what do you mean ? based on post#9 is existed in H19 as in pic 1
Actually, I think the value that I asked about was in H14 in pic 1. However, I had actually asked the wrong question. I meant to say "I can't see that value anywhere in B2:B9 of the original data."
H9 in your results is the value that I asked about BS 165 R13C R624 THI
and that value does not appear in B2:B9 of the original data (pic 1). I do note though that B9 in pic1 of post 9 was BS 165R13C R624 THI but B9 in pic 2 has changed to BS 165 R13C R624 THI so I assume the pic 1 value was another error?

If so, try this

VBA Code:
Sub MatchItems()
  Dim a As Variant, b As Variant
  Dim rFound As Range
  Dim i As Long
 
  a = Range("A2", Range("B" & Rows.Count).End(xlUp)).Value
  ReDim b(1 To UBound(a), 1 To 2)
  For i = 1 To UBound(a)
    Set rFound = Columns("H").Find(What:=a(i, 2), LookAt:=xlWhole)
    If Not rFound Is Nothing Then
      b(i, 1) = a(i, 1)
      b(i, 2) = a(i, 2)
    End If
  Next i
  With Range("G2", Range("H" & Rows.Count).End(xlUp))
    .ClearContents
    .Resize(UBound(b)).Value = b
  End With
End Sub
 
Upvote 0
Solution
so I assume the pic 1 value was another error?
It's too bad explanation :eek::eek::eek::eek::eek:
I was hurry up . it's not excuses . this is what happened . my apologies for bad explenation
although of all of things happend , you have patience. if another member I expect leaving this thread. I don't exaggerate , but you keep going until solve it .

it's great !!
many thanks for your time & help :):):):):)
 
Upvote 0
You're welcome.

It is important that you give accurate sample data and expected results though as that is all helpers have to go on. They are not familiar with your data and expectations like you are.
As you have seen here, being in a hurry & making mistakes actually slows the process down. ;)
 
Upvote 0

Forum statistics

Threads
1,216,069
Messages
6,128,608
Members
449,460
Latest member
jgharbawi

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