G
Guest
Question from a newbie. Ok, this may sound simple but I have no idea what to do. I use this macro below that I got from this site. It searches column "A" for duplicates and adds other specific columns. What I need to find out is how to set it up to test for multiple duplicates (I will have 4 test values) (ie. If Columns A, D, E, F in row one are the same as in row two then add columns G,H,I,J and then delete row two
If anyone needs anymore information I will gladly provide it, as my working knowledge doesn't go much past "record a macro" or copy and paste one that I find here into a workbook. I have no idea if this is even possible, but it would help alot if someone can help me, as the file I need to do this to is about 8,000 rows long and will tak eme forever to do by hand
Sub Main(
Dim rng As Rang
Dim rngFirst As Rang
Dim c As Rang
Dim lRow As Lon
Dim cLastRow As Lon
'hard coded range :-
cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Set rng = Range("A2", Range("A" & Rows.Count).End(xlUp)
For lRow = 1 To rng.Rows.Coun
'step thru all cells :-
If Len(rng.Cells(lRow).Text) > 0 The
Set c = rng.Find(What:=rng.Cells(lRow)
If Not c Is Nothing The
Set rngFirst =
D
Set c = rng.FindNext(c
If (Not c Is Nothing) And
(c.Address <> rngFirst.Address) The
'sum data (as if the 6th col. were a qty
rngFirst.Offset(0, 2) =
c.Offset(0, 2) + rngFirst.Offset(0, 2
rngFirst.Offset(0, 3) =
c.Offset(0, 3) + rngFirst.Offset(0, 3
rngFirst.Offset(0, 4) =
c.Offset(0, 4) + rngFirst.Offset(0, 4
rngFirst.Offset(0, 5) =
c.Offset(0, 5) + rngFirst.Offset(0, 5
rngFirst.Offset(0, 6) =
c.Offset(0, 6) + rngFirst.Offset(0, 6)
'or copy data. whatever
'(this copies 3th thru 4th cell to right of c
'to 5th cell to right of rngFirst
'Range(c.Offset(0, 3), c.Offset(0, 4)).Copy
' rngFirst.Offset(0, 5
'remove this instance of the I
c.Clea
Els
Exit D
End I
Loo
End I
End I
Next lRo
'Remove all rows where we clear the I
rng.Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delet
End Su
Thank you very much for your time and consideration, as I am los
Erin Myers
If anyone needs anymore information I will gladly provide it, as my working knowledge doesn't go much past "record a macro" or copy and paste one that I find here into a workbook. I have no idea if this is even possible, but it would help alot if someone can help me, as the file I need to do this to is about 8,000 rows long and will tak eme forever to do by hand
Sub Main(
Dim rng As Rang
Dim rngFirst As Rang
Dim c As Rang
Dim lRow As Lon
Dim cLastRow As Lon
'hard coded range :-
cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Set rng = Range("A2", Range("A" & Rows.Count).End(xlUp)
For lRow = 1 To rng.Rows.Coun
'step thru all cells :-
If Len(rng.Cells(lRow).Text) > 0 The
Set c = rng.Find(What:=rng.Cells(lRow)
If Not c Is Nothing The
Set rngFirst =
D
Set c = rng.FindNext(c
If (Not c Is Nothing) And
(c.Address <> rngFirst.Address) The
'sum data (as if the 6th col. were a qty
rngFirst.Offset(0, 2) =
c.Offset(0, 2) + rngFirst.Offset(0, 2
rngFirst.Offset(0, 3) =
c.Offset(0, 3) + rngFirst.Offset(0, 3
rngFirst.Offset(0, 4) =
c.Offset(0, 4) + rngFirst.Offset(0, 4
rngFirst.Offset(0, 5) =
c.Offset(0, 5) + rngFirst.Offset(0, 5
rngFirst.Offset(0, 6) =
c.Offset(0, 6) + rngFirst.Offset(0, 6)
'or copy data. whatever
'(this copies 3th thru 4th cell to right of c
'to 5th cell to right of rngFirst
'Range(c.Offset(0, 3), c.Offset(0, 4)).Copy
' rngFirst.Offset(0, 5
'remove this instance of the I
c.Clea
Els
Exit D
End I
Loo
End I
End I
Next lRo
'Remove all rows where we clear the I
rng.Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delet
End Su
Thank you very much for your time and consideration, as I am los
Erin Myers