Macro sending e-mail to one or more consignees

JOJESS

New Member
Joined
Dec 8, 2017
Messages
1
Hi all,

I have a pivot table. Below is a snap picture from it. What I need, is an e-mail to be sent if a unique date (for instance 2017-12-12) have more than two equal times (for instance 13:45).

If not possible, I would at least need to have a color indicator that highlights those rows.

Thanks for the ones having this knowledge and sharing it.

KR Jessica

__________________________________________
[TABLE="width: 399"]
<tbody>[TR]
[TD]2017-12-12[/TD]
[TD]N/A[/TD]
[TD]B066325C[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]1345[/TD]
[TD]B068160A[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]1345[/TD]
[TD]B068391A[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]1345[/TD]
[TD]B068160B[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]745[/TD]
[TD]B068268BG[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]745[/TD]
[TD]B068268CG[/TD]
[/TR]
</tbody><colgroup><col><col><col></colgroup>[/TABLE]
[TABLE="width: 399"]
<tbody>[TR]
[TD]2017-12-12[/TD]
[TD] N/A[/TD]
[TD]B066325C[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]1345[/TD]
[TD]B068160A[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]1345[/TD]
[TD]B068391A[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]1345[/TD]
[TD]B068160B[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]745[/TD]
[TD]B068268BG[/TD]
[/TR]
[TR]
[TD]2017-12-12[/TD]
[TD]745[/TD]
[TD]B068268CG




[/TD]
[/TR]
</tbody><colgroup><col><col><col></colgroup>[/TABLE]
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
.
Here's one way:

Code:
Option Explicit
Sub Macro1()
     
    Const lngStartRow As Long = 1 'Starting Row number for the data. Change to suit.
    Const strStartCol As String = "B" 'Starting column letter for the duplicates. Change to suit.
     
    Dim lngLastCol    As Long
    Dim lngMyCol      As Long
    Dim lngLastRow    As Long
    Dim lngMyRow      As Long
    Dim strMyCol      As String
    Dim strPK         As String 'Primary Key
    Dim xlnCalcMethod As XlCalculation
     
    Application.ScreenUpdating = False
         
     'Note the sheet must have data in it or the next lines will error out!!
    lngLastCol = Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    lngLastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
     
     'Remove any previous duplicate highlighting
    strMyCol = Left(Cells(1, lngLastCol).Address(True, False), Application.WorksheetFunction.Search("$", Cells(1, lngLastCol).Address(True, False)) - 1)
    Range(Cells(lngStartRow, strStartCol), Cells(lngLastRow, strMyCol)).Interior.Color = xlNone
     
     'Create Primary Key formula
    For lngMyCol = Asc(strStartCol) - 64 To lngLastCol
        strMyCol = Left(Cells(1, lngMyCol).Address(True, False), Application.WorksheetFunction.Search("$", Cells(1, lngMyCol).Address(True, False)) - 1)
        If lngMyCol = Asc(strStartCol) - 64 Then
            strPK = "=" & strMyCol & lngStartRow
        Else
            strPK = strPK & "&" & strMyCol & lngStartRow
        End If
    Next lngMyCol
     
    strMyCol = Left(Cells(1, lngLastCol + 1).Address(True, False), Application.WorksheetFunction.Search("$", Cells(1, lngLastCol + 1).Address(True, False)) - 1)
     
     'Copy Primary Key formula down dataset
    Range(Cells(lngStartRow, strMyCol), Cells(lngLastRow, strMyCol)).Formula = strPK
     
     'Loop through Primary Key field and highlight duplicates
    For lngMyRow = lngStartRow To lngLastRow
        If Evaluate("COUNTIF(" & Range(strMyCol & lngStartRow & ":" & strMyCol & lngStartRow & lngLastRow).Address(True, True) & "," & Range(strMyCol & lngMyRow).Address(False, True) & ")") > 1 Then
           Range(Cells(lngMyRow, Asc(strStartCol) - 64), Cells(lngMyRow, lngLastCol)).Interior.Color = RGB(255, 255, 0) 'Highlight duplicates in yellow. Change to suit.
        End If
    Next lngMyRow
        
    'Delete helper column
    Columns(strMyCol).EntireColumn.Delete
     
     
    Application.ScreenUpdating = True
         
  
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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