Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Input Validation using VBA

Hello,
I have been told it is possible to create input validation using visual
basic so I could give a warning if the input was within a certain range of
values,
and a stop message if it was between another.
So in my situation I want a stop message if the input is below that of
another cell, and a warning if it is double the value of the same other cell.
The cell is using direct input.
Thank you.
Richard.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Input Validation using VBA

Something like this

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

If .Value < 0 Or .Value 10 Then

MsgBox "Invalid value, correct it"
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"VoxBox-Richard" wrote in message
...
Hello,
I have been told it is possible to create input validation using visual
basic so I could give a warning if the input was within a certain range of
values,
and a stop message if it was between another.
So in my situation I want a stop message if the input is below that of
another cell, and a warning if it is double the value of the same other
cell.
The cell is using direct input.
Thank you.
Richard.



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
What is input validation? Rich Excel Discussion (Misc queries) 1 September 7th 09 03:44 PM
Validation Input Text Chris waller Excel Discussion (Misc queries) 1 March 5th 09 09:30 PM
input masks and validation archiboy Excel Discussion (Misc queries) 3 October 11th 05 03:05 PM
Whole Number Validation in Input Box Dkt24 Excel Programming 3 April 11th 05 08:22 PM
Help with VBA Input Validation Jim[_56_] Excel Programming 1 January 24th 05 10:29 PM


All times are GMT +1. The time now is 06:47 PM.

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

About Us

"It's about Microsoft Excel"