#1   Report Post  
GAIL HORVATH
 
Posts: n/a
Default Any Ideas?

I hane a column in a spread sheet whose values at times are repeats of the cell above. I want that row deleted if the value is the same as the cell above is there a way to do it programaticallY?

e.g.
A B C D E
Acct # MedRec# field field field
112233 xxx xxx xxx xxx
112233 xxx xxx xxx xxx
123123 xxx xxx xxx xxx
123412 xxx xxx xxx xxx
123412 xxx xxx xxx xxx

I would want the rows in bold red deleted

--
Gail M Horvath





  #2   Report Post  
JMB
 
Posts: n/a
Default

you could copy the following macro into a VBA module of your workbook
(Alt-F11, select your workbook from the project windo, click Insert/Module,
then paste the code into the code window), select all the cells in the column
that contains your duplicate data and run the macro:

Sub DeleteDupes()
Dim RangeToDelete As Range

On Error Resume Next

If Selection.Columns.Count < 1 Then Exit Sub

For Each x In Selection
If x.Value = Cells(x.Row - 1, x.Column).Value Then
If RangeToDelete Is Nothing Then
Set RangeToDelete = x
Else: Set RangeToDelete = Union(RangeToDelete, x)
End If
End If
Next x

RangeToDelete.EntireRow.Delete

End Sub

As always - make sure you back up your workbook before you run any macros.
Once the rows are deleted, you can't use the undo button to put them back.



"GAIL HORVATH" wrote:

I hane a column in a spread sheet whose values at times are repeats of the cell above. I want that row deleted if the value is the same as the cell above is there a way to do it programaticallY?

e.g.
A B C D E
Acct # MedRec# field field field
112233 xxx xxx xxx xxx
112233 xxx xxx xxx xxx
123123 xxx xxx xxx xxx
123412 xxx xxx xxx xxx
123412 xxx xxx xxx xxx

I would want the rows in bold red deleted

--
Gail M Horvath

x

  #3   Report Post  
bj
 
Posts: n/a
Default

If you are sure that ther only duplicate information of interest is in Column
A
one method is to put in a helper column
in B2 enter
=if(A2=A1,1,0)
Copy down to the end of your data
use auto filter on the helper column and select 1
Select all and delete rows
deactivate the Autofilter and delete the Helper column.

"GAIL HORVATH" wrote:

I hane a column in a spread sheet whose values at times are repeats of the cell above. I want that row deleted if the value is the same as the cell above is there a way to do it programaticallY?

e.g.
A B C D E
Acct # MedRec# field field field
112233 xxx xxx xxx xxx
112233 xxx xxx xxx xxx
123123 xxx xxx xxx xxx
123412 xxx xxx xxx xxx
123412 xxx xxx xxx xxx

I would want the rows in bold red deleted

--
Gail M Horvath

x

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
Any Ideas Greg B Excel Discussion (Misc queries) 7 May 16th 05 03:41 AM
Need a ISWorkday Function -- Any Ideas Mark Excel Worksheet Functions 5 March 29th 05 01:58 AM
Vlookup won't work, any other ideas? Huw Excel Worksheet Functions 0 February 17th 05 04:31 PM
Assign Macro to button in Excel doesnt work Any ideas? Mike@Becketts Excel Discussion (Misc queries) 2 December 20th 04 02:47 PM
formula from Excel97 doesn't work in Excel2003,any ideas why? nic Excel Worksheet Functions 6 November 8th 04 04:40 PM


All times are GMT +1. The time now is 03:53 PM.

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

About Us

"It's about Microsoft Excel"