Someone please help me with this one.

i8ur4re

Board Regular
Joined
Mar 1, 2015
Messages
97
Good day,

I have a list that looks something like this:

ItemNumber DescriptionCost
100-13Open Coil Innerspring Demo78
1020025Rocker Recliner/Pikara219.99
1020035Loveseat/Pikara/Gunsmoke254.99
1020038Sofa/Pikara/Gunsmoke269.99
1030025Rocker Recliner/Carnell/Brown259.99
1030087Reclining Power Sofa/Carnell519.99
1030088Reclining Sofa/Carnell/Brown419.99
1030094Double Rec Loveseat w/Console419.99
1030096DBL REC PWR Loveseat w/Console519.99
1030098Power Rocker Recliner/Carnell309.99

<tbody>
</tbody>

I have 3 columns, each column as shown above has the following headers; Item Number, Description, and Cost.

I would like to insert "Item Number" under each new set of numbers. A set of numbers is the first 3 numbers.
For example; The first "Item Number" 100-13 is one number. I would like to insert a "Item Number" under it so I can sort the new set of numbers which in this case would be "1020025-1020038".

The 102 is the primary number that this list must be sorted by. The next set is 103 (1030025-1030098). Under each set of numbers i would like to add a blank row so i can insert the headers that correspond to what that column indicates ("Item Number, Description, Cost").

At the end it should look something like this:

ItemNumber DescriptionCost
100-13Open Coil Innerspring Demo78
ItemNumberDescriptionCost
1020025Rocker Recliner/Pikara219.99
1020035Loveseat/Pikara/Gunsmoke254.99
1020038Sofa/Pikara/Gunsmoke269.99
ItemNumberDescriptionCost
1030025Rocker Recliner/Carnell/Brown259.99
1030087Reclining Power Sofa/Carnell519.99
1030088Reclining Sofa/Carnell/Brown419.99
1030094Double Rec Loveseat w/Console419.99
1030096DBL REC PWR Loveseat w/Console519.99
1030098Power Rocker Recliner/Carnell309.99

<tbody>
</tbody>

<tbody>
</tbody>

Its a very large list of items, over 6300 items to be exact. Macros are welcome.
ANY HELP WOULD BE APPRECIATED.
You guys are awesome. Thank you
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
This assumes your first header is in cell A1.
Code:
Sub InsertMoreHeaders()
Dim rHdrs As Range, i As Long
Set rHdrs = Range("A1:C1")
Application.ScreenUpdating = False
For i = Range("A" & Rows.Count).End(xlUp).Row To 3 Step -1
    If Left(Cells(i, "A"), 3) <> Left(Cells(i - 1, "A"), 3) Then
        Cells(i, "A").EntireRow.Insert
        With Cells(i, "A")
            .Resize(1, 3).Value = rHdrs.Value
            .Resize(1, 3).Font.Bold = True
        End With
    End If
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I was JUST about to suggest a helper cell with left 3 formula and then subtotals but that code that Joemo suggested is CLEARLY the better choice.
 
Upvote 0
THANK YOU SO MUCH. I really appreciate it. You are a life saver, not the candy, just a life saver. Kudos to you
 
Upvote 0
Least i can do. I just have one little problem, sorry i never mentioned it in the post. But i also have letters for some of the item numbers, i realized this worked beautifully for the numbers. What if i have letters as well. For example; B044-52,45,23, that would be one set of numbers, the next one would be B045, etc. I noticed that the macro did work for some of the letters, but not all. Any ideas. Thank you in advance
 
Upvote 0
Least i can do. I just have one little problem, sorry i never mentioned it in the post. But i also have letters for some of the item numbers, i realized this worked beautifully for the numbers. What if i have letters as well. For example; B044-52,45,23, that would be one set of numbers, the next one would be B045, etc. I noticed that the macro did work for some of the letters, but not all. Any ideas. Thank you in advance
Can you clarify? You may have both numbers and letters at the start of an entry. If numbers, then the first 3 digits define a "set". If letters, there is a single letter followed by 3 digits that define a 'set". Is that correct?

Can you post a few samples of the letters type to go with the data in your OP?
 
Upvote 0
The letter in the beginning lets me know what kind of item it is (B=Bed). The numbers preceding is the item number.

The letters change, but the 3 numbers following that letter are for a set. Below is an example.

B470-94
B470-96
B470-97
B473-31
B473-36
B473-39

<colgroup><col></colgroup><tbody>
</tbody>
 
Upvote 0
The letter in the beginning lets me know what kind of item it is (B=Bed). The numbers preceding is the item number.

The letters change, but the 3 numbers following that letter are for a set. Below is an example.

B470-94
B470-96
B470-97
B473-31
B473-36
B473-39

<tbody>
</tbody>
So it's always a single letter followed by 3 digits? Would you ever have a transition from say, B473-39 to 473 ...... and if yes, do you want a separator between those cells?
 
Upvote 0
I was JUST about to suggest a helper cell with left 3 formula and then subtotals but that code that Joemo suggested is CLEARLY the better choice.
I agree with using a helper cell. While Joe's solution does have a certain elegance, it means that the table is de-normalized. That may limit its use in other features (or at least make some features more complicated.)
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

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