LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Compare cell and msg

And, to be consistent with my use of
an object variable for B2, it would be
better to replace:

MsgBox "CELL B2 CANNOT BE LESS " _
& "THAN CELL A2, TRY AGAIN"


with
MsgBox Prompt:="CELL " & Rng2.Address(0, 0) _
& " CANNOT BE LESS " _
& "THAN CELL A2, TRY AGAIN"

---
Regards.
Norman


"Norman Jones" wrote in message
...
Hi JLGWhiz,

To avoid a Run-time 13 error if the value
of a multi-cell range is changed, more
robust might be the following version:

'=========
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim Rng2 As Range

With Me
Set Rng = .Range("A2")
Set Rng2 = .Range("B2")
End With

If Not Intersect(Rng2, Target) Is Nothing Then
If Rng2.Value < Rng.Value Then
MsgBox "CELL B2 CANNOT BE LESS " _
& "THAN CELL A2, TRY AGAIN"
Rng2.Select
End If
End If
End Sub
'<<=========



---
Regards.
Norman


 
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
Compare text string of a cell in Column A VS another cell in Colum Tan New Users to Excel 2 August 1st 07 09:45 AM
Compare text string of a cell in Column A VS another cell in Colum Tan Excel Discussion (Misc queries) 1 August 1st 07 09:03 AM
Compare text string of a cell in Column A VS another cell in Colum Tan Excel Worksheet Functions 1 August 1st 07 09:01 AM
Compare text string of a cell in Column A VS another cell in Colum Tan Excel Programming 0 July 30th 07 05:12 PM
How do I compare cells and if FALSE compare to next cell in EXCEL Cindie Excel Worksheet Functions 0 March 24th 06 05:29 PM


All times are GMT +1. The time now is 02:18 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"