![]() |
|
#2
|
|||
|
|||
|
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
|
| Tags |
| mail macro, validation |
| Thread Tools | |
| Display Modes | |
|
|
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 |
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 |
send/receive mail every 5 min.?
|
bsoderror | Outlook | 2 | 07-06-2009 04:36 AM |