Find PartNumbers

flds

Board Regular
Joined
Jun 19, 2008
Messages
73
Hello friends,

I am looking to create a VBA code to do the following. Is it possible?
I have a data range with many columns (ie. Description, Vendor, Part number……).
Column ‘A’ "Description" has string of data which includes part numbers, vendor and other info. (2500+ rows)
Column ‘H’ , 'I' & 'J' are blank
Column ‘M’ has Alphanumeric part numbers.
Column ‘N’ has code numbers.
Columns ‘M’ and ‘N’ go together
I need to find the part numbers from column M by searching in Column ‘A’, (should be able to use wildcard search)
If a match is found, I need to copy the code number in column ‘N’ and place it in column ‘H’ on the same row the match is found in Column ‘A’. and also the cell address of column 'N' to be placed in column 'I'. (for verification purpose).
If no Match is found place a "NO" in Column 'J'.
I hope I have explained this correctly.

Question
How long will it take to search all the part numbers from column 'M', it need to search each cell and find a match?

Thanks
FLDS
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
flds,

What version of Excel and Windows are you using?

Can you post a screenshot of the actual raw data worksheet?

To post your data, you can download and install one of the following two programs:
Excel Jeanie
MrExcel HTML Maker

Or, when using Internet Explorer, just put borders around your data in Excel and copy those cells into your post.
See reply #2 the BLUE text in the following link:
http://www.mrexcel.com/forum/about-board/444901-how-create-table-like-aladin.html#post2198045

If you are not able to give us screenshots:
You can upload your workbook to Box Net,
sensitive data changed
mark the workbook for sharing
and provide us with a link to your workbook.
 
Upvote 0
Hi Hiker95
Thanks for your reply.

Correction to my post #1. "If no Match is found place a "NO" in Column ('J') Should read "O" ."

I have attached a link to the file uploaded to Box Net. Click Link Below
https://app.box.com/s/7tfyvcsqhxl0v1j0sb1n

I hope this will help.

Thanks
FLDS
 
Upvote 0
Hi Hiker95

Sorry, forgot to mention I am using excel 2010 and OS windows 7.

FLDS
 
Upvote 0
flds,

Thanks for the workbook.

It would appear that the results you posed below the raw data is not the same as below?

Sample raw data:


Excel 2007
ABHIMNO
2DescriptionVendorCodeCell AdrsPart No.CodeY/N
3kdfjlki kjdfk d14df1245 kjdfkjkljMcMaster124S245A12345
4mmfd klkdlnm ;14sw264 fdflkl ;l;fdDaniel4587925B23456
5jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites123GF4523C34567
6mmfd klkdl 14sw264 fdflkl ;l;fdDaniel14SW264D45678
7kjlkdfjkklf kljf fdsjkj 124S245 kljdkfjksdRands236A1458E56789
8kdfj 124sd957 kjlkdsfj jklfdklRolls124SD957F67890
9jkjk jjkldflk j kkdkfklj 236a1458d kldfjjRuston648D123G78901
10jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites569F145H89012
11jkljfkjkfd dkjlkfd jkklfkkl ;4587925 ffd;lfk 'Dramel14DF1245J901234
12jkjk jjkldflk j kkdkfklj ;=236a1458d kldfjjRuston678D145K012345
13kdfj sjh-;124sd957 kjlkdsfj jklfdklRolls
14
Sheet1


After the macro (the resulting cells are displayed with a YELLOW background just so you can check the accuracy):


Excel 2007
ABHIMNO
2DescriptionVendorCodeCell AdrsPart No.CodeY/N
3kdfjlki kjdfk d14df1245 kjdfkjkljMcMasterE56789N7124S245A12345
4mmfd klkdlnm ;14sw264 fdflkl ;l;fdDanielJ901234N114587925B23456
5jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites123GF4523C34567No
6mmfd klkdl 14sw264 fdflkl ;l;fdDanielB23456N414SW264D45678
7kjlkdfjkklf kljf fdsjkj 124S245 kljdkfjksdRandsG78901N9236A1458E56789
8kdfj 124sd957 kjlkdsfj jklfdklRollsF67890N8124SD957F67890
9jkjk jjkldflk j kkdkfklj 236a1458d kldfjjRuston648D123G78901No
10jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites569F145H89012No
11jkljfkjkfd dkjlkfd jkklfkkl ;4587925 ffd;lfk 'DramelA12345N314DF1245J901234
12jkjk jjkldflk j kkdkfklj ;=236a1458d kldfjjRuston678D145K012345No
13kdfj sjh-;124sd957 kjlkdsfj jklfdklRolls
14
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Option Explicit
Sub FindCodeCellAdrs()
' hiker95, 12/14/2013
' http://www.mrexcel.com/forum/excel-questions/745111-find-partnumbers.html
Dim c As Range, fr As Long
Application.ScreenUpdating = False
For Each c In Range("M3", Range("M" & Rows.Count).End(xlUp))
  fr = 0
  On Error Resume Next
  fr = Application.Match("*" & c & "*", Columns(1), 0)
  On Error GoTo 0
  If fr = 0 Then
    With Cells(c.Row, "O")
      .Value = "No"
      .HorizontalAlignment = xlCenter
    End With
  ElseIf fr > 0 Then
    With Cells(c.Row, "H")
      .Value = Cells(fr, "N")
      .HorizontalAlignment = xlCenter
    End With
    With Cells(c.Row, "I")
      .Value = "N" & fr
      .HorizontalAlignment = xlCenter
    End With
  End If
Next c
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the FindCodeCellAdrs macro.
 
Upvote 0
flds,

After the macro, Part Number 124SD957 is listed twice in column A - see the GREEN background cells:


Excel 2007
ABHIMNO
2DescriptionVendorCodeCell AdrsPart No.CodeY/N
3kdfjlki kjdfk d14df1245 kjdfkjkljMcMasterE56789N7124S245A12345
4mmfd klkdlnm ;14sw264 fdflkl ;l;fdDanielJ901234N114587925B23456
5jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites123GF4523C34567No
6mmfd klkdl 14sw264 fdflkl ;l;fdDanielB23456N414SW264D45678
7kjlkdfjkklf kljf fdsjkj 124S245 kljdkfjksdRandsG78901N9236A1458E56789
8kdfj 124sd957 kjlkdsfj jklfdklRollsF67890N8124SD957F67890
9jkjk jjkldflk j kkdkfklj 236a1458d kldfjjRuston648D123G78901No
10jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites569F145H89012No
11jkljfkjkfd dkjlkfd jkklfkkl ;4587925 ffd;lfk 'DramelA12345N314DF1245J901234
12jkjk jjkldflk j kkdkfklj ;=236a1458d kldfjjRuston678D145K012345No
13kdfj sjh-;124sd957 kjlkdsfj jklfdklRolls
14
Sheet1
 
Upvote 0
Hi hiker95,

Thank you for your response.
Yes, Column 'A' could have multiple duplicate part numbers.

When running the marco the results are not pointing to the code in column 'N'.

I have uploaded another file (xlsm) to Box Net, colour highlighted to show how the results should look like.
The link is https://app.box.com/s/503lecbjkx63smwif8sf

I hope you will see it in colour.

Thanks for your time.
FLDS
 
Upvote 0
flds,

I think I have followed your written instruction correctly?

If we are searching for part number 124S245 in cell M3

We find in in column A in cell A7

Then cell H3 should result in E56789

And, cell I3 should result in N7


Excel 2007
ABCDEFGHIJKLMNO
1Raw Data
2DescriptionVendorEquip.MaterialXYZABCCodeCell AdrsPart No.CodeY/N
3kdfjlki kjdfk d14df1245 kjdfkjkljMcMasterE56789N7124S245A12345
4mmfd klkdlnm ;14sw264 fdflkl ;l;fdDanielJ901234N114587925B23456
5jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites123GF4523C34567No
6mmfd klkdl 14sw264 fdflkl ;l;fdDanielB23456N414SW264D45678
7kjlkdfjkklf kljf fdsjkj 124S245 kljdkfjksdRandsG78901N9236A1458E56789
8kdfj 124sd957 kjlkdsfj jklfdklRollsF67890N8124SD957F67890
9jkjk jjkldflk j kkdkfklj 236a1458d kldfjjRuston648D123G78901No
10jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites569F145H89012No
11jkljfkjkfd dkjlkfd jkklfkkl ;4587925 ffd;lfk 'DramelA12345N314DF1245J901234
12jkjk jjkldflk j kkdkfklj ;=236a1458d kldfjjRuston678D145K012345No
13kdfj sjh-;124sd957 kjlkdsfj jklfdklRolls
14
Sheet1




If I have NOT followed your written instruction correctly, then:

Please explain your logic.


I missed this part of your instructions:
I need to find the part numbers from column M
by searching in Column ‘A’, (should be able to use wildcard search)
If a match is found, I need to copy the code number in column ‘N’
and place it in column ‘H’ on the same row the match is found in Column ‘A’.
and also the cell address of column 'N' to be placed in column 'I'.
(for verification purpose).

Be back in a little while.
 
Last edited:
Upvote 0
Hi Hiker95,

Sorry for that.


“I missed this part of your instructions:
I need to find the part numbers from column M
by searching in Column ‘A’, (should be able to use wildcard search)
If a match is found, I need to copy the code number in column ‘N’ which is Adjacent to Searched Part number ‘M’. and place it in column ‘H’ on the same row the match is found in Column ‘A’. and also the cell address of the “Code” that was placed in column ‘H’ to be placed in column 'I'. (for verification purpose).”

Example: to Post #8
On Row 7 = A7 Part Number found, H7 should contain Code from N3 (A12345, which is adjacent to searched Part Number M3) and I7 should read “N3” as cell address.
On Row 8 = is correct
On Row 13 = Is the same as row 8 (H13 contains Code N8 (F67890), and I13 should read “N8” as cell address.

I hope I have explained correctly now.

FLDS
 
Upvote 0
flds,

Sample raw data:


Excel 2007
ABHIMNO
1Raw Data
2DescriptionVendorCodeCell AdrsPart No.CodeY/N
3kdfjlki kjdfk d14df1245 kjdfkjkljMcMaster124S245A12345
4mmfd klkdlnm ;14sw264 fdflkl ;l;fdDaniel4587925B23456
5jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites123GF4523C34567
6mmfd klkdl 14sw264 fdflkl ;l;fdDaniel14SW264D45678
7kjlkdfjkklf kljf fdsjkj 124S245 kljdkfjksdRands236A1458E56789
8kdfj 124sd957 kjlkdsfj jklfdklRolls124SD957F67890
9jkjk jjkldflk j kkdkfklj 236a1458d kldfjjRuston648D123G78901
10jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites569F145H89012
11jkljfkjkfd dkjlkfd jkklfkkl ;4587925 ffd;lfk 'Dramel14DF1245J901234
12jkjk jjkldflk j kkdkfklj ;=236a1458d kldfjjRuston678D145K012345
13kdfj sjh-;124sd957 kjlkdsfj jklfdklRolls
14
Sheet1



After the new macro:


Excel 2007
ABHIMNO
1Raw Data
2DescriptionVendorCodeCell AdrsPart No.CodeY/N
3kdfjlki kjdfk d14df1245 kjdfkjkljMcMasterJ901234N11124S245A12345
4mmfd klkdlnm ;14sw264 fdflkl ;l;fdDanielD45678N64587925B23456
5jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites123GF4523C34567No
6mmfd klkdl 14sw264 fdflkl ;l;fdDanielD45678N614SW264D45678
7kjlkdfjkklf kljf fdsjkj 124S245 kljdkfjksdRandsA12345N3236A1458E56789
8kdfj 124sd957 kjlkdsfj jklfdklRollsF67890N8124SD957F67890
9jkjk jjkldflk j kkdkfklj 236a1458d kldfjjRustonE56789N7648D123G78901No
10jkfhjjdks kjldfflk hhk1297c12 k;ldfkksdkBrites569F145H89012No
11jkljfkjkfd dkjlkfd jkklfkkl ;4587925 ffd;lfk 'DramelB23456N414DF1245J901234
12jkjk jjkldflk j kkdkfklj ;=236a1458d kldfjjRustonE56789N7678D145K012345No
13kdfj sjh-;124sd957 kjlkdsfj jklfdklRollsF67890N8
14
Sheet1


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Option Explicit
Sub FindCodeCellAdrsV2()
' hiker95, 12/15/2013
' http://www.mrexcel.com/forum/excel-questions/745111-find-partnumbers.html
Dim a As Variant, i As Long, ii As Long, n As Long, lr As Long
lr = Cells.Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, False).Row
a = Range("A1:O" & lr)
For i = 3 To UBound(a, 1)
  n = 0
  If a(i, 13) <> "" Then
    For ii = 3 To UBound(a, 1)
      If InStr(LCase(a(ii, 1)), LCase(a(i, 13))) Then
        n = n + 1
        a(ii, 8) = a(i, 14)
        a(ii, 9) = "N" & i
      End If
    Next ii
    If n = 0 Then a(i, 15) = "No"
  End If
Next i
Range("A1").Resize(UBound(a, 1), UBound(a, 2)) = a
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the FindCodeCellAdrsV2 macro.
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,640
Members
448,974
Latest member
DumbFinanceBro

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