LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add cells if values are the same in multiple columns

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).Enti reRow.Delet
End Su

Thank you very much for your time and consideration, as I am los

Erin Myers
 
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
How to count with values from multiple columns? PF Excel Worksheet Functions 5 November 19th 09 01:57 AM
find values in multiple cells and paste row values izzyt1972 Excel Discussion (Misc queries) 5 December 26th 07 10:14 PM
Totals f(x) text values in multiple columns and cells jkl Excel Discussion (Misc queries) 10 May 10th 07 08:09 AM
Lookup in Multiple Columns, Return Multiple Values andy62 Excel Worksheet Functions 3 July 6th 06 02:36 AM
Find Values 0 Over Multiple Columns CalumMurdo Kennedy Excel Programming 0 September 18th 03 08:24 AM


All times are GMT +1. The time now is 12:28 AM.

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"