ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search Column, If match found then add two values. (https://www.excelbanter.com/excel-programming/385701-search-column-if-match-found-then-add-two-values.html)

[email protected]

Search Column, If match found then add two values.
 
Hello all,

Ive found this group extremely useful before, so I thought id ask a
question of my own since I cant find anything to help or come up with
anything that solves it myself.

I have a sheet that lists who watched our online event with the times
theyve logged in and out, sometimes you can have multiple connections
from one person but I want them considered as the same person with the
total viewing shown. I would like to search by the FullName field(The
only unique field I have) and if it finds a match then I want to add
the total time watched values, sometimes the names are way down the
column.

So I want to search D(fullname), If match then add the values from the
cells in the row the match was found but on column L(total time)
together with the original and then delete the duplicate row if
possible.

Any help would be most appreciated

Yours

S MacKintosh


merjet

Search Column, If match found then add two values.
 
Sub SumAndDelete()
Dim c As Range
Dim rng As Range
Dim iEnd As Long
Dim iCt As Long
Dim ws As Worksheet

Set ws = Sheets("Sheet1")
iEnd = ws.Range("D1").End(xlDown).Row
Set rng = ws.Range("D2:D" & iEnd)
For Each c In rng
For iCt = iEnd To c.Row + 1 Step -1
If c = ws.Range("D" & iCt) Then
c.Offset(0, 8) = c.Offset(0, 8) + ws.Range("L" & iCt)
ws.Rows(iCt).Delete
End If
Next iCt
Next c
End Sub

Hth,
Merjet



[email protected]

Search Column, If match found then add two values.
 
Ah that works like a charm, thank you!!



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com