Highlighting similar cells

TM74

Board Regular
Joined
Aug 2, 2007
Messages
132
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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
'- CellRangeAdd is the Range you will be adding
'---------------------------------------------------------
Dim x As Long, y As Long, i As Long

Application.Volatile
x = Ce.Rows.Count
y = CellRangeAdd.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
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

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