# Highlighting similar cells

#### TM74

##### Board Regular
Hi,

I am trying to design a spreasheet that would help my company identify stock that is under old product codes. Unfortunately our head office loves to change the product codes of our goods at the drop of a hat. For instance:

Product ABC00001 may have a slightly different screw used in its manufacture and so it becomes product ABC00002.

The end result of this is that we end up stock piling equipment, as our sales system is geared up to sell the latest product codes, ignoring the older codes.

Therefore, I have a spreadsheet containing all our products that we currently have in stock, in all our locations, and on another worksheet I have my customers order. I would like to find a way to show all products that I have that start with the same first 7 digits. For example product ABC00002 would look for all products that start with ABC0000 and so on. Information could then be returned via an Index Match formula or something.

I have searched microsoft sites for a solution to what is essentially a simple problem, but with no avail.

Can anyone help?

### Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome to the board!

I am quite sure this can be done with normal excel functions but nothing is working the way I would think it would. Therefore, I have put together this simple UDF. Hope this helps!

Code:
``````Option Explicit
Function Sumlen(Ce As Range, CellChoice As String, Length As Integer, CellRangeAdd As Range)
'---------------------------------------------------------
'- Ce is the Range you are checking
'- CellChoice is the string which you wish to compare with
'- Length is the number of characters you wish to compare
'---------------------------------------------------------
Dim x As Long, y As Long, i As Long

Application.Volatile
x = Ce.Rows.Count

For i = 1 To x
If Left(Ce.Cells(i, 1).Value, Length) = Left(CellChoice, Length) Then
Sumlen = Sumlen + CellRangeAdd.Cells(i, 1).Value
End If
Next

End Function``````

Thanks, I'll give that a go.

Replies
2
Views
279
Replies
2
Views
427
Replies
11
Views
570
Replies
6
Views
124
Replies
1
Views
193

1,218,837
Messages
6,144,755
Members
450,567
Latest member
Mplz

### 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.

### Which adblocker are you using?

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

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