A Challenge for you Excel experts

mljohn

Board Regular
Joined
Aug 26, 2004
Messages
196
Office Version
  1. 365
Platform
  1. Windows
I have a large list of parts that I want to change how the data is laid out.

It was laid out by the part number and which machines went to that part number. The machines were all together in one cell.

Now I want to have each machine have it's own row.

I'll need a way to automate the process since I have so many records.

I have a link to my Box.net account that shows an example spreadsheet.

http://www.box.net/shared/cl8l0vi9qh

I hope you are up to the challenge, I sure need the help.

Thanks

Matt
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
mljohn,


Sample new raw data on worksheet Sheet1:


Excel Workbook
ABCDEFGHIJ
1CategoryPrinterCompatible withOemPartNoMSEPartNoPremiumPartNoPageYieldPriceMSRPStreetPrice
2TONERBROTHERDCP-7030, 7040, 7045N,HL-2140, 2150N, 2170W, MFC-7320, 7340, 7345DN, 7345N, 7440N, 7840WDR36058-03-361458-03-361012,000$46.00$75.00$99.99
3TONERBROTHERDCP-8020, DCP-8025D, HL-1650, HL-1650N, HL-1650NPLUS, HL-1670N, HL-1850, HL-1870n, HL-5040, HL-5050, HL-5050LT, HL-5070N, MFC-8420, MFC-8420 D, MFC-8820D, MFC-8820DNDR50058-03-501458-03-501020,000$62.00$109.00$198.29
4
Sheet1





After the same macro on a new worksheet Results:


Excel Workbook
ABCDEFGHIJ
1CategoryPrinterCompatible withOemPartNoMSEPartNoPremiumPartNoPageYieldPriceMSRPStreetPrice
2TONERBROTHERDCP-7030DR36058-03-361458-03-361012,000$46.00$75.00$99.99
3TONERBROTHER7040DR36058-03-361458-03-361012,000$46.00$75.00$99.99
4TONERBROTHER7045NDR36058-03-361458-03-361012,000$46.00$75.00$99.99
5TONERBROTHERHL-2140DR36058-03-361458-03-361012,000$46.00$75.00$99.99
6TONERBROTHER2150NDR36058-03-361458-03-361012,000$46.00$75.00$99.99
7TONERBROTHER2170WDR36058-03-361458-03-361012,000$46.00$75.00$99.99
8TONERBROTHERMFC-7320DR36058-03-361458-03-361012,000$46.00$75.00$99.99
9TONERBROTHER7340DR36058-03-361458-03-361012,000$46.00$75.00$99.99
10TONERBROTHER7345DNDR36058-03-361458-03-361012,000$46.00$75.00$99.99
11TONERBROTHER7345NDR36058-03-361458-03-361012,000$46.00$75.00$99.99
12TONERBROTHER7440NDR36058-03-361458-03-361012,000$46.00$75.00$99.99
13TONERBROTHER7840WDR36058-03-361458-03-361012,000$46.00$75.00$99.99
14
15
16
17TONERBROTHERDCP-8020DR50058-03-501458-03-501020,000$62.00$109.00$198.29
18TONERBROTHERDCP-8025DDR50058-03-501458-03-501020,000$62.00$109.00$198.29
19TONERBROTHERHL-1650DR50058-03-501458-03-501020,000$62.00$109.00$198.29
20TONERBROTHERHL-1650NDR50058-03-501458-03-501020,000$62.00$109.00$198.29
21TONERBROTHERHL-1650NPLUSDR50058-03-501458-03-501020,000$62.00$109.00$198.29
22TONERBROTHERHL-1670NDR50058-03-501458-03-501020,000$62.00$109.00$198.29
23TONERBROTHERHL-1850DR50058-03-501458-03-501020,000$62.00$109.00$198.29
24TONERBROTHERHL-1870nDR50058-03-501458-03-501020,000$62.00$109.00$198.29
25TONERBROTHERHL-5040DR50058-03-501458-03-501020,000$62.00$109.00$198.29
26TONERBROTHERHL-5050DR50058-03-501458-03-501020,000$62.00$109.00$198.29
27TONERBROTHERHL-5050LTDR50058-03-501458-03-501020,000$62.00$109.00$198.29
28TONERBROTHERHL-5070NDR50058-03-501458-03-501020,000$62.00$109.00$198.29
29TONERBROTHERMFC-8420DR50058-03-501458-03-501020,000$62.00$109.00$198.29
30TONERBROTHERMFC-8420DDR50058-03-501458-03-501020,000$62.00$109.00$198.29
31TONERBROTHERMFC-8820DDR50058-03-501458-03-501020,000$62.00$109.00$198.29
32TONERBROTHERMFC-8820DNDR50058-03-501458-03-501020,000$62.00$109.00$198.29
33
Results





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 ReorgData()
' hiker95, 03/26/2011
' http://www.mrexcel.com/forum/showthread.php?t=538961
Dim w1 As Worksheet, wR As Worksheet
Dim LR As Long, a As Long, Sp, s As Long, H As String, NR As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
If Not Evaluate("ISREF(Results!A1)") Then Worksheets.Add(After:=w1).Name = "Results"
Set wR = Worksheets("Results")
wR.UsedRange.Clear
Set wR = Worksheets("Results")
wR.Range("A1:J1").Value = w1.Range("A1:J1").Value
LR = w1.Cells(Rows.Count, 1).End(xlUp).Row
NR = 2
For a = 2 To LR Step 1
  H = ""
  H = Replace(w1.Cells(a, 3), " ", "")
  Sp = Split(H, ",")
  s = UBound(Sp) + 1
  wR.Range("A" & NR).Resize(s, 2).Value = w1.Range("A" & a).Resize(, 2).Value
  wR.Range("C" & NR).Resize(s).Value = Application.Transpose(Sp)
  wR.Range("D" & NR).Resize(s, 7).Value = w1.Range("D" & a).Resize(, 7).Value
  NR = wR.Range("A" & Rows.Count).End(xlUp).Offset(1).Row + 3
Next a
wR.Range("C2:G" & NR + s).HorizontalAlignment = xlCenter
wR.Range("H2:J" & NR + s).NumberFormat = "[$$-409]#,##0.00_);([$$-409]#,##0.00)"
wR.UsedRange.Columns.AutoFit
wR.Activate
Application.ScreenUpdating = True
End Sub


Then run the ReorgData macro.
 
Upvote 0
mljohn,

I noticed that when I ran your macro that some of the machines didn't have their full name. Is there a way to have the program look for this and fix it.

Yes, I would need a complete list of all the possable items in Compatible with.
 
Upvote 0
I'm sorry, I'm not saying that your macro caused the problem. I'm saying that until I ran your macro I didn't notice that my vendor did not enter the data correctly and I wanted to know if you could help me add the parts of the machine names that they didn't add.
 
Upvote 0
mljohn,


I noticed that when I ran your macro that some of the machines didn't have their full name. Is there a way to have the program look for this and fix it.

I wanted to know if you could help me add the parts of the machine names that they didn't add.


Yes, I would need a complete list of all the possible complete items for column Compatible with.
 
Upvote 0
I'm not sure what you are asking for. I gave you a link to my complete spreadsheet.

Matt
 
Upvote 0
mljohn,

I need the complete list, like this, for all parts/part numbers:
DCP-8020
DCP-8025D
HL-1650
HL-1650N
HL-1650NPLUS
HL-1670N
HL-1850
HL-1870n
HL-5040
HL-5050
HL-5050LT
HL-5070N
MFC-8420
MFC-8420D
MFC-8820D
MFC-8820DN
 
Upvote 0
I wish I could but that is what I need.

The data entry people took short cuts when entering the data.

There is a pattern. For example: Row #271

HL-5130
5140
5150D These are all the HL- machines
5150DLT They need the "HL-" added to them
5170DN
5170DNLT

DCP-8040 These are all the DCP- machines
8045D They need the "DCP-" added to them

MFC-8220 These are all the MFC- machines
8440 They need the "MFC-" added to them
8640D
8840D
8840DN

If you go thru the RESULTS worksheet you will see the pattern.

Is there a way to have Excel automatically add the missing data?
Also since this may make changes that were not needed, is it possible to mark the ones that were changed? Such as an extra column with an "X" or color the cell that was changed.

Here is the link: http://www.box.net/shared/n97y7f0z6l

thanks

Matt
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,854
Members
452,948
Latest member
UsmanAli786

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