Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro to delete duplicate cell

I have a large spreadsheet that I need to clean up. My data is kept by row,
so some rows have the same information in two adjacent cells. An example is
below in rows 2 through 5.

1 DB A HF SR SCR PI
2 SAW DB SR DR DB DB
3 SAW DB SR DR DB DB
4 SAW DB SR DR DB DB
5 SAW DB SR DR DB DB

Is there a macro that can automatically delete the 2nd duplicate cell
entirely so that the remaining cells will shift to the left? I can delete
them manually one at a time and shift the remaining cells left, but I'd like
to be able to clean up the entire sheet at once.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Macro to delete duplicate cell

Hi Greetings!!

Please try the below code to clean up consecutive duplicate rows. Please
adjust the Function incase you have more number of columns.

Dim intRow
Dim strData

intRow = 2

Do while Range("A" & intRow) < ""

If GetRowDatatoString(intRow-1) = GetRowDatatoString(intRow) Then
Rows(intRow).Entirerow.Delete
intRow = intRow -1
End If

intRow = intRow + 1
Loop

Function GetRowDatatoString(intRow)
GetRowDatatoString = Range("A" & intRow) & Range("B" & intRow) & Range("C"
& intRow) & Range("D" & intRow) & Range("E" & intRow)
End Function


"PointerMan" wrote:

I have a large spreadsheet that I need to clean up. My data is kept by row,
so some rows have the same information in two adjacent cells. An example is
below in rows 2 through 5.

1 DB A HF SR SCR PI
2 SAW DB SR DR DB DB
3 SAW DB SR DR DB DB
4 SAW DB SR DR DB DB
5 SAW DB SR DR DB DB

Is there a macro that can automatically delete the 2nd duplicate cell
entirely so that the remaining cells will shift to the left? I can delete
them manually one at a time and shift the remaining cells left, but I'd like
to be able to clean up the entire sheet at once.

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
Delete Duplicate Header Macro Workbook Excel Programming 2 February 20th 09 01:07 PM
Macro to delete duplicate entries Ray[_12_] Excel Programming 2 August 20th 04 02:12 AM
Macro to delete duplicate records Horselover Excel Programming 2 July 1st 04 03:06 PM
Macro to delete duplicate data in row Tony Excel Programming 2 November 13th 03 03:17 PM
Macro to delete duplicate data Tony Excel Programming 0 November 12th 03 10:52 PM


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

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"