Computing.Net > Forums > Office Software > Merge rows in Excel & del duplicate

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Merge rows in Excel & del duplicate

Reply to Message Icon

Name: KuDoZ
Date: February 2, 2006 at 15:18:33 Pacific
OS: WIN2000
CPU/Ram: Cel 2ghz
Comment:

Hi all, having a problem trying to merge rows in a client database due to duplications. What I need to do is merge all values into one row. Format is as such

Jack Jones 22/1/9 $120 - -
Jack Jones 22/1/9 - $240 -
Jack Jones 22/1/9 - - $320

what I'm trying to do

Jack Jones 22/1/9 $120 $240 $320

There are 700 rows x 32 columns.
Only 390 of these rows are unique though - which is what i need to merge it down to.

I found a few scripts already but it's removing some members and leaving me with 260 rows, unfortunately my VB is too rusty to edit it though.

Any help would be great,

Scott



Sponsored Link
Ads by Google

Response Number 1
Name: KuDoZ
Date: February 2, 2006 at 15:23:07 Pacific
Reply:

Oh, and it might help to know that Col 1 contains the unique identifier - "Member Number".


0

Response Number 2
Name: Jennifer SUMN
Date: February 2, 2006 at 15:55:50 Pacific
Reply:

What version of Excel do you have? If you have 2003, there is a "Merge Cells Wizard" add in available.

Or, you could use the "Concatenate" function.

Soylent Green is PEOPLE!!!


0

Response Number 3
Name: KuDoZ
Date: February 2, 2006 at 16:05:39 Pacific
Reply:

Excel 2000, yeah.. forgot to mention that yeah.


0

Response Number 4
Name: KuDoZ
Date: February 2, 2006 at 16:40:02 Pacific
Reply:

Current VB script I'm running on it - amalgamation of 2 I found on the net.


Option Explicit
Dim firstR, curR, lastR, testR
Dim C, r
Dim Col
Dim srcsheet As Worksheet
Dim whattodelete As Range

Sub consolidater()

Set whattodelete = Rows(1)
firstR = 1
For lastR = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(lastR + 1, 1) <> Cells(firstR + 1, 1) Then
Call mergit(firstR, lastR)
firstR = lastR + 1
End If
Next lastR
whattodelete.Delete
End Sub
Sub mergit(firstR, lastR)
Debug.Print "first/last", firstR, lastR
For curR = firstR To lastR ' curR, col should be replaced with first non blank

For Col = 2 To 42
If Cells(curR, Col) = "" Then ' current cell is blank,
For testR = firstR To lastR ' look at all other values in column
If Cells(testR, Col) <> "" Then ' and take the first one not blank
Cells(curR, Col) = Cells(testR, Col)
End If
Next testR
End If
Next Col
Set whattodelete = Union(whattodelete, Rows(firstR))
Next curR
End Sub
Public Sub DeleteDuplicateRows()
'
' This macro deletes duplicate rows in the selection. Duplicates are
' counted in the COLUMN of the active cell.

Dim Col As Integer
Dim r As Long
Dim C As Range
Dim N As Long
Dim V As Variant
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Col = ActiveCell.Column

If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If

N = 0
For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
If Application.WorksheetFunction.CountIf(Rng.Columns(1), V) > 1 Then
Rng.Rows(r).EntireRow.Delete
N = N + 1
End If
Next r

EndMacro:

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Merge rows in Excel & del duplicate

Cannot merge cells in excel www.computing.net/answers/office/cannot-merge-cells-in-excel/1622.html

increase no of rows in excel shet www.computing.net/answers/office/increase-no-of-rows-in-excel-shet/8272.html

Minimize Rows in Excel www.computing.net/answers/office/minimize-rows-in-excel/8830.html