Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create new column based on duplicate row 1

Status
Not open for further replies.

elsenorjose

Technical User
Oct 29, 2003
684
0
0
US
Sorry if the title wasn't very descriptive. Here is my question:

I have 2 columns in a worksheet:

Code:
code     bytes
18227	3592161
19750	246215
19750	225779
19751	83192
19751	65371
19752	20347
19752	20400
19753	55080
19753	54213

I need to display the data like this:

Code:
code     bytes1    bytes2
18227	3592161   0
19750	246215    225779
19751	83192     65371
19752	20347     20400
19753	55080     54213

How can I accomplish this?

Thank you.
 
Two-step process.

Assuming that your row header "code" is in cell A1.

Enter the formula

=IF(A3=A2,B3,0)

into cell C2 and copy down however many rows you have.

Enter the formula

=IF(C1=0,TRUE, FALSE)

into cell D2 and copy down.

Turn on auto-filter for columns A, B, C and D.

Filter column D to show only TRUE.

Hide column D.

Ok, maybe four steps.

 
hi elsenorjose:

If the original entries are in columns A and B, and the newly arranged entries are in columns D to F, then column D houses Unique entries from column A (using AdvancedFilter), and

the formula in cell

E2 is ... =INDEX($B$2:$B$10,MATCH($D2,$A$2:$A$10,0))
and
F2 is ... =IF(COUNTIF($A$2:$A$10,$D2)>1,INDEX($B$2:$B$10,MATCH($D2,$A$2:$A$10,0)+COLUMNS($A:A)),0)

these formulas are then copied down.

see following illustration

Code:
code	 bytes		  code	 bytes1	bytes2
18227	3592161		18227	3592161   0    
19750	246215		 19750	246215	225779
19750	225779		 19751	83192	 65371
19751	83192		  19752	20347	 20400
19751	65371		  19753	55080	 54213
19752	20347				
19752	20400				
19753	55080				
19753	54213


Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
 
Have a third column to distinguish byte1 items from byte2 items, like this:
Code:
="Byte "&COUNTIF($A$2:$A2,A2)
( please note the specifics of the $ signs in this formula ... the test range has a fixed start point and a relative end-point )

Have a title at the top of this column, say "Label" and create a pivottable to create your table, with "Code" as the Row field, "Label" as the column field, and "bytes" as the Data field ( Sum of bytes ). You can switch off Grand Totals for Rows in Table Options.

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Yogi's solution seemed the simplest and most efficient and worked perfectly, but thank you mintjulep and GlennUK for your solution, too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top