VBA change dup values within a group

Sahil123

Well-known Member
Joined
Oct 31, 2011
Messages
673
Hi All,

I was advised to create a new thread as the question is different

I have this code thanks yo Fluff to help me put 0 on duplicates where the name and time (Column A & B) are the same but i came across an issue where i need to check to see if column C
which is the location exists within a group table

So i have table called GroupData and i have all the locations put into a group

I want to apply the same logic as above but also look at the group

In Column C I have the location which will be different however some location are grouped (I have another grouped table called group in another spreadsheet)

GroupedTable (location GroupedFolder\GroupData
Filename GroupedData.xlsx
GroupedTable is on sheet GroupedData


Ie

Birmingham - Group 1
Liverpool - Group 1
London - Group 2
Leicester - Group 3
Bradford - Group 2

I need to amend the code to also look at this table and where there is a match in datetime and Name (Like we currently have)
also look at whether the group location in the same group and only put 0 in the duplicates in that group

ie if Bham, Liverpool and London had same name and time - then keep 1 of the 1 the group 1 data an and put 0's in the other and keep London as that is in another group however if there was another Group 2 ieBradford then have the dups as 0

I was thinking of adding an extra temp column at end of the data set column (AB) will be the column that will be at the end, have a vlookup formula to pull back Group and then do the concatenation check with adding thiscolumn in too

I would have preferred to add this column in memory but that aint a biggie and then just delete out that temp column

is that a better way of doing it?

Here is the existing code

VBA Code:
Sub UpdateDuplicates()
   Dim Cl As Range
   Dim Tmp As String
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
         Tmp = Cl.Value2 & "|" & Cl.Offset(, 1).Value
         If Not .exists(Tmp) Then
            .Add Tmp, Nothing
         Else
            Cl.Offset(, 3).Resize(, 2).Value = 0
            Cl.Offset(, 6).Value = 0
         End If
      Next Cl
   End With
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top