LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Error handling in macro

I have a macro that displays a message box if a formula result is true,
and calls another macro if it is false using an "IF..Then..Else" line.
The True/False is based on a specially formatted date being compared to
data in that cell, but there are time when a user will enter a word or
phrase in the comparison box, producing a #VALUE in the cell that the
macro doesn't recognize. I'm guessing this means I will need an error
handler in the macro to deal with that, and I've tried several, but I
can't get it to work. Bottom line, I need the message box to appear if
the value is True(as above and works great), and the macro from Module
22 to run if anything else appears in that cell.
Thanks to all.

Here is the code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Cells.Count 1 Then Exit Sub 'only one cell at a time

'exit unless it Is D7 that changed
If Intersect(Target, Me.Range("$D$7")) Is Nothing Then Exit Sub

If IsEmpty(Target.Value) Then Exit Sub
If Range("d4") = True Then
MsgBox "Check Driver's License Expiration Date", 48, "Exprired Driver's
License"
Range("D7").Select
Else
Call Module22.Look_Here1
'the macro To Call when D7 changes



End If

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 08:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"