Rolling duplicate columns

HeRoseInThree

Board Regular
Joined
Jan 11, 2018
Messages
103
Every couple of days I add data to column A. After I do, I insert another column A. I would like to see, if at any time, i have duplicate data in 3 consecutive columns.
 
OK, for this I opted to use the Pop Up message instead of highlighting (if we need to highlight, that will involve more code to find exactly where these values occur).
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim val As Variant

'   Exit sub if multiple cells updated at once
    If Target.CountLarge > 1 Then Exit Sub
    
'   Exit sub if update is not in 1st column
    If Target.Column > 1 Then Exit Sub
    
'   Check to see if entry is equal to values in new two columns in same row
    If Target <> "" Then
        val = Target.Value
'       See if value is found in column B
        If Application.WorksheetFunction.CountIf(Columns("B:B"), val) > 0 Then
'           See if value is found in column C
            If Application.WorksheetFunction.CountIf(Columns("C:C"), val) > 0 Then
'               Pop up message box alerting user
                MsgBox val & " is found in columns A, B, and C", vbOKOnly
            End If
        End If
    End If

End Sub
 
Upvote 0
Solution

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Building on this. If I add a new column A, that changes all of my other formulas. Is there a way to add a new column (every 2 days) and have it add the new column in the formula?

Example. I have in M2 a formula: =COUNTIF(A$2:C$30,L2)
But, when I add a new column A, the new formula will be =COUNTIF(B$2:D$30,M2)
 
Upvote 0
Building on this. If I add a new column A, that changes all of my other formulas. Is there a way to add a new column (every 2 days) and have it add the new column in the formula?

Example. I have in M2 a formula: =COUNTIF(A$2:C$30,L2)
But, when I add a new column A, the new formula will be =COUNTIF(B$2:D$30,M2)
This sounds like a whole different question that probably warrants its own thread.
 
Upvote 0

Forum statistics

Threads
1,215,417
Messages
6,124,787
Members
449,188
Latest member
Hoffk036

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