Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jip jip is offline
external usenet poster
 
Posts: 8
Default Contraction of rows

Platform: Windows 2000/Excel 2000


Is there anybody out here who is able to help me solving following
Excel-case:

I have an Excel-price file consists of approximately 4000 rows and 6
columns,

First column consist of consecutive numbers each usual attached/connected
with a price (the price can be the same but not necessarily).

I need to make a macro/VB-code which can do following job:

If a number occur more than once (as for instance 101075 or 101078, shown in
the example down under) the macro/VB-code shall replace all repetition-rows
with only one row, but same time add. the prices belonging to the same
number..hope this explanation makes it clear????


Example

Before change:

Number Price
101074 2000
101075 5412
101075 243
101075 8492
101076 105531
101077 244
101078 5456
101078 81512

After the change has been implemented:

Number Price
101074 2000
101075 14147
101076 105531
101077 244
101078 86968

I am looking forward that you are able to help.

JIP


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Contraction of rows

Unless this is something you have to do repetetively, it would be easier
just to do it manually

Assume you data starts in A2 and Column G is open. in G2 put in the formula

=if(countif($A$2:A2)=1,Sumif($A:$A,A2,$B:$B),"Dele te")

Drag fill that down the column (double click the lower right corner of the
selection highlight on the little square as one way).

Now select Column G and do Edit=Copy, then Edit=PasteSpecial and select
Values. This replaces the formulas with the values they display.

Now select row1 and do Data=Filter=AutoFilter
in the column G dropdown select Delete
Select rows 2:4000 (use the name box as an easy way - type in 2:4000<cr)
and do Edit=Delete
now do Data=Filter=Autofilter to remove the autofilter. You should now
have your result data.

If you need a macro, turn on the macro recorder while you do this manually,
then clean it up to generalize it.

--
Regards,
Tom Ogilvy


"jip" wrote in message
...
Platform: Windows 2000/Excel 2000


Is there anybody out here who is able to help me solving following
Excel-case:

I have an Excel-price file consists of approximately 4000 rows and 6
columns,

First column consist of consecutive numbers each usual attached/connected
with a price (the price can be the same but not necessarily).

I need to make a macro/VB-code which can do following job:

If a number occur more than once (as for instance 101075 or 101078, shown

in
the example down under) the macro/VB-code shall replace all

repetition-rows
with only one row, but same time add. the prices belonging to the same
number..hope this explanation makes it clear????


Example

Before change:

Number Price
101074 2000
101075 5412
101075 243
101075 8492
101076 105531
101077 244
101078 5456
101078 81512

After the change has been implemented:

Number Price
101074 2000
101075 14147
101076 105531
101077 244
101078 86968

I am looking forward that you are able to help.

JIP




  #3   Report Post  
Posted to microsoft.public.excel.programming
jip jip is offline
external usenet poster
 
Posts: 8
Default Contraction of rows

Hi Tom,

I'm not sure I have fully understood the IF-sentence.

The reason I am asking is that it does not work correct I get syntax errors
if I just copy it into
the Excel file as you described.

Can you explain to me how it works?

$A$2 what does it mean, exactly?
"Delete": This function does not work, do you know the explanation?

When I separate the IF-sentence into smaller pieces: COUNTIF and SUMIF they
work without
syntax errors but I still have to make some small changes before they do:

=countif($A$2:A2)=1 become =(COUNTIF($A$2;A2)=1 (the result I get is a true
or false)


=Sumif($A:$A,A2,$B:$B) become =SUMIF(A:A;A2;B:B) (I get a number as result)


"Delete": Excel does not know this "command" at all ????

Hopefully you are able to help.


JIP
"Tom Ogilvy" skrev i en meddelelse
...
Unless this is something you have to do repetetively, it would be easier
just to do it manually

Assume you data starts in A2 and Column G is open. in G2 put in the

formula

=if(countif($A$2:A2)=1,Sumif($A:$A,A2,$B:$B),"Dele te")

Drag fill that down the column (double click the lower right corner of the
selection highlight on the little square as one way).

Now select Column G and do Edit=Copy, then Edit=PasteSpecial and select
Values. This replaces the formulas with the values they display.

Now select row1 and do Data=Filter=AutoFilter
in the column G dropdown select Delete
Select rows 2:4000 (use the name box as an easy way - type in 2:4000<cr)
and do Edit=Delete
now do Data=Filter=Autofilter to remove the autofilter. You should now
have your result data.

If you need a macro, turn on the macro recorder while you do this

manually,
then clean it up to generalize it.

--
Regards,
Tom Ogilvy


"jip" wrote in message
...
Platform: Windows 2000/Excel 2000


Is there anybody out here who is able to help me solving following
Excel-case:

I have an Excel-price file consists of approximately 4000 rows and 6
columns,

First column consist of consecutive numbers each usual

attached/connected
with a price (the price can be the same but not necessarily).

I need to make a macro/VB-code which can do following job:

If a number occur more than once (as for instance 101075 or 101078,

shown
in
the example down under) the macro/VB-code shall replace all

repetition-rows
with only one row, but same time add. the prices belonging to the same
number..hope this explanation makes it clear????


Example

Before change:

Number Price
101074 2000
101075 5412
101075 243
101075 8492
101076 105531
101077 244
101078 5456
101078 81512

After the change has been implemented:

Number Price
101074 2000
101075 14147
101076 105531
101077 244
101078 86968

I am looking forward that you are able to help.

JIP






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto extract data & inserts rows additional rows automatically Meeru Excel Discussion (Misc queries) 3 September 9th 09 01:46 PM
Enabling option „Format rows“ to hide/unhide rows using VBA-code? ran58 Excel Discussion (Misc queries) 0 July 28th 09 03:46 PM
Group Contraction/Expansion in Protected Worksheet rj Excel Worksheet Functions 0 August 19th 05 08:26 PM
Pivot Tables: How do I show ALL field rows, including empty rows?? [email protected] Excel Worksheet Functions 2 April 8th 05 06:21 PM
number expansion and contraction tom donino Excel Worksheet Functions 2 December 23rd 04 08:11 PM


All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"