Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2015, 03:22 AM
saurabhlotankar saurabhlotankar is offline need assistance in send mail macro Windows XP need assistance in send mail macro Office 2010 32bit
Novice
need assistance in send mail macro
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default need assistance in send mail macro

Hi guys,



Please find attached sheet. If we click on validate button it highlights all cells in mandatory columns which are blank and pops up a message on the screen stationg "Please fill up mandatory fields.

My question is if there are no blanks in the mandatory columns. then macro should not pop up that message it should draft an email.

i have designed the code but its either highlighting blanks cells or drafting email. am not bale to combine both the things.

kindly assist.
Attached Files
File Type: xlsm Sample.xlsm (25.5 KB, 14 views)
Reply With Quote
  #2  
Old 08-13-2015, 09:55 AM
NoSparks NoSparks is offline need assistance in send mail macro Windows 7 64bit need assistance in send mail macro Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

You should really use Option Explicit and declare all your variables, not just some of them.
Have a look at this page.

Give this macro a try
Code:
Public Sub HighLightEmptyCells()
    Dim myRange As Range
    Dim myCell As Range
    Dim lastrow As Long
    Dim anyBlanks As Boolean
    
With ActiveSheet
    lastrow = .Cells.Find("*", .Cells(1, 1), , , xlByRows, xlPrevious).Row
    Set myRange = Application.Union(.Range("B3:D" & lastrow), .Range("F3:F" & lastrow))
    anyBlanks = False
    
    For Each myCell In myRange
        If myCell.Value = "" Then
            myCell.Interior.Color = vbRed
            anyBlanks = True
        Else
            myCell.Interior.Color = xlNone
        End If
    Next myCell
    
    If anyBlanks = True Then
        MsgBox " Please fill up Mandatory Fields Highlighted in Red"
        Exit Sub
    Else
        MsgBox "OK -- Ready to draft email"
        ' Application.Dialogs(xlDialogSendMail).Show "xyz@abc.com"
    End If
End With
End Sub
Reply With Quote
  #3  
Old 08-16-2015, 09:40 PM
saurabhlotankar saurabhlotankar is offline need assistance in send mail macro Windows XP need assistance in send mail macro Office 2010 32bit
Novice
need assistance in send mail macro
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Thanks NoSparks. I am new to this coding hence i worte that leanthy code. But your is awesome.
Its working perfect. I just neeed to add one more condition to it. If there are any duplicate value in column D(i.e.header 3), then again macro should highlight those cells( with duplicate values) and pop up a msg stating there are duplicate values in column D.
So ideally this macro should do 2 checks
first : Highlight blank cells if any in mandatory field and pop msg stating the same. (which we have already done)
second: highlight Duplicate value cells in column D and pop up msg stating the same.

and if no blank cells and no duplicate values then send mail.

If you can assist with that then it would be awesome.

Thanks.
Reply With Quote
  #4  
Old 08-19-2015, 11:27 PM
saurabhlotankar saurabhlotankar is offline need assistance in send mail macro Windows XP need assistance in send mail macro Office 2010 32bit
Novice
need assistance in send mail macro
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Hi NoSparks,

I have written the below mentioned code for highlighting duplicate values if any in column D.

Public Sub MarkDuplicates()
Dim iWarnColor As Integer
Dim rng As Range
Dim rngCell As Variant
Dim myRangeUpdateAA As Range


Set rLastCell = ActiveSheet.Cells.Find("*", ActiveSheet.Cells(1, 1), , , xlByRows, _
xlPrevious)
lastrow = rLastCell.Row
Set rng = ActiveSheet.Range("D3" & lastrow)
iWarnColor = xlThemeColorAccent2
For Each rngCell In rng.Cells
vVal = rngCell.Text
If (WorksheetFunction.CountIf(rng, vVal) = 1) Then
rngCell.Interior.Pattern = xlNone
Else
rngCell.Interior.ColorIndex = iWarnColor
End If
Next rngCell
End Sub

Now am stuck on how to incorporate this code with our earlier code. So that our final macro will be ready with both condiotions i.e. no mandatory fields should be blank and there should not be any duplcate value in column D. In both pop msg should populate and mail should not be drafted.

Request you to kindly assist.

Thanks a lot.
Reply With Quote
  #5  
Old 08-26-2015, 07:19 AM
saurabhlotankar saurabhlotankar is offline need assistance in send mail macro Windows XP need assistance in send mail macro Office 2010 32bit
Novice
need assistance in send mail macro
 
Join Date: May 2015
Posts: 29
saurabhlotankar is on a distinguished road
Default

Any luck anyone?
Reply With Quote
Reply

Tags
mail macro, validation



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro code should find inv no in folder and send attachhed mail. visha_1984 Outlook 0 01-30-2013 05:08 AM
Hijacked e mail send. igardos44 Outlook 0 05-24-2012 07:32 AM
need assistance in send mail macro Send e-mail by macro plamenbv Excel Programming 1 04-16-2012 05:25 AM
Cant Send E-Mail dmack98 Outlook 0 03-09-2012 10:59 AM
need assistance in send mail macro send/receive mail every 5 min.? bsoderror Outlook 2 07-06-2009 04:36 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft