Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default DV error message with a cell value

Hi All,


Is it possible to get a cell value to be displayed as an
error meessage in a data validation?

for eg if i have limited the number in A1 to be equal or
multples of B1 how can i get an eror message somethinf
like "amount should be multples of " & B1.value
(the value in B1 may vary)

TIA
Soniya
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default DV error message with a cell value

You could use an event macro to change the data validation error message
whenever you changed B1.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Range("b1")) Is Nothing Then Exit Sub

On Error GoTo errHandler:

With Range("a1")
If .Value Mod Target.Value < 0 Then
Application.EnableEvents = False
.ClearContents
End If
.Validation.ErrorMessage _
= "Must be a multiple of " & Target.Value & "."
End With

errHandler:
Application.EnableEvents = True
End Sub


Right click on the worksheet tab that should have this behavior. Select View
code and paste this in.

I also looked at the value in A1. If it's not a multiple of the current value
in B1, then it gets cleared. You may not want that.



Soniya wrote:

Hi All,

Is it possible to get a cell value to be displayed as an
error meessage in a data validation?

for eg if i have limited the number in A1 to be equal or
multples of B1 how can i get an eror message somethinf
like "amount should be multples of " & B1.value
(the value in B1 may vary)

TIA
Soniya


--

Dave Peterson

Reply
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
Error message: Too many different cell formats Jenhow Excel Discussion (Misc queries) 1 November 14th 07 06:36 PM
error message: Too many different cell formats. Vinceburg Excel Discussion (Misc queries) 3 April 18th 06 06:20 PM
Error Message In Cell Kearcomm Excel Discussion (Misc queries) 3 March 19th 06 03:31 PM
Cell Copy Error Message gswan Excel Discussion (Misc queries) 0 March 15th 05 10:07 PM
I get an error message "Too many different cell formats" Bob Lindal Excel Worksheet Functions 1 February 6th 05 01:01 AM


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