deleting duplicate rows and inserting rows based on cell differences

deleting duplicate rows and inserting rows based on cell differences

Post by Michael Bertra » Tue, 15 Aug 1995 04:00:00



Hi,  someone have solutions to the following problems:

1)  I want to be able to delete entire rows which are identical to each other.  
The rows that would be identical would be one on top of another and I only
have to compare 4 or 5 cells from each row to determine if they are identical.

and then once these identical rows are deleted...

2) I would like to be able to insert rows between other rows based on the
information contained in one column.  e.g.  a list sorted by date where I will
be able to insert a couple of lines between different dates,  separating the
days if you will.

Thanks for any information.
Bert

 
 
 

deleting duplicate rows and inserting rows based on cell differences

Post by Ed » Wed, 16 Aug 1995 04:00:00


Quote:> The subject line says it all...

Here's a slick utility I wrote in Excel 4.0 where is checks
the identity of two values and if there the same..it sums
up some values in other columns, deletes the initial row
and inserts a row between the two...it may be a little
confusing at first...but study it...it's all there..

 SUM_UP()
=ECHO(FALSE)
 new_count=0
 db_rows=ROWS(!Database)
=FOR("count99",1,db_rows)
=    select_db_row()
=    IF(count99>1)
=        
select_db_row(current_record+((count99-1)+new_count))
=    END.IF()
=    SET.NAME("selected_record",SELECTION())
=    IF(ISBLANK(ACTIVE.CELL()))
=        select_db_row(current_record+1)
=        SET.NAME("selected_record",SELECTION())
=    END.IF()
=    SET.NAME("series",OFFSET(selected_record,,1,1,1))
=    FOR.CELL("count9",OFFSET(!Database,,1,,1))
=        select_db_row(current_record+1)
=        SET.NAME("trial_record",SELECTION())
         db_row=ROW(trial_record)
=        IF(ROWS(!Database)>db_rows)
             db_rows=ROWS(!Database)
=        END.IF()
=        IF(db_row>ROWS(!Database))
=            BREAK()
=        END.IF()
=        IF(REFTEXT(trial_record)=REFTEXT(selected_record))
             current_record=current_record+1
=            select_db_row(current_record)
=        END.IF()
=        IF(ISBLANK(ACTIVE.CELL()))
=            select_db_row(current_record+1)
=        END.IF()
=        SET.NAME("trial_record",SELECTION())
=        SET.NAME("dup_series",OFFSET(trial_record,,1,1,1))
=        IF(ISBLANK(dup_series))
=            RETURN()
=        END.IF()
=        IF(ISBLANK(series))
=            RETURN()
=        END.IF()
=        IF(dup_series<>series)
=            INSERT(2)
             new_count=new_count+1
=            BREAK()
=        END.IF()
=        IF(dup_series=series)
=sum_FUNDS()
=            EDIT.DELETE(2)
=            select_db_row(current_record-1)
=        END.IF()
=        IF(ROW(selected_record)>db_rows)
=            BREAK()
=        END.IF()

=    NEXT()
=NEXT()
=RETURN()

 select_db_row()
=ARGUMENT("record_no",1)
=IF(ISERROR(record_no))
     record_no=1

=ELSE.IF(record_no<1)
     record_no=1

=ELSE.IF(db_rows<=record_no)
     record_no=db_rows-1
=END.IF()
=SELECT(OFFSET(!Database,(record_no),,1))
 current_record=record_no
=RETURN()

 sum_FUNDS()

=MATCH("ALLOCATED FUNDS",INDEX(!Database,1,),0)
=FORMULA("=("&OFFSET(trial_record,,B83-1,1,1)&"+"&OFFSET(se
lected_record,,B83-1,1,1)&")",OFFSET(selected_record,,B83-1
,1,1))
=SELECT(selected_record)
=COPY()
=PASTE.SPECIAL(3)

=SELECT(trial_record)
=RETURN()

there are 3 functions here...one calling another...check it
out and good luck!

Ed

 
 
 

deleting duplicate rows and inserting rows based on cell differences

Post by Lynn » Tue, 29 Aug 1995 04:00:00


This involves a macro that looks at each row. Says is A = B, if so delete
B. If not then what other criteria you are looking for and then do
whatever that requires. It is a basic loop. You also need the criteria for
ending the loop.  For more details, please ask. And perhaps send me a copy
of what you are doing.
Lynn Wegley
Spreadsheet advisor on AOL's Mac Business Forum
(Keyword: MBS)
 
 
 

1. VBA code to delete row based on vaule of one cell within that row?

HI!
I am writing a little macro in Excel 97 and I have hit a little block.
I am sure this is do-able, I just lack the knowledge.
I have a cell (well actually I have a worksheet full of cells, but I
think I can work out the looping from one cell to the next...) that
contains a numerical value that is either positive or negative.
If the value is 0 or negitive I want the macro to delete the entire row.
Any suggestions? Thanks in advance!

Galen

2. Norton Commander for OS/2

3. SQL: delete rows based on a column being like-compared to other rows

4. Group Logon Scripts

5. Inserting row quan based on cell value?

6. Machine Learning

7. Excel - Deleting duplicate rows

8. CD-ROM Questions

9. Trouble with writing a macro to delete duplicated rows

10. HIGHLIGHTING/ DELETING DUPLICATE ROWS

11. DELETING DUPLICATE ROW ENTRIES

12. Excel: Paste Linking--Problem Updating 2nd sheet after inserting or deleting rows

13. Any patch for delete and insert same row in a function ( transaction )