Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Data validation to force cell population

I am trying to force users to populate a cell (R20) with information
if cell (B20) equals a value off of a list. My first preference is
that the user is not be able to leave the row (20) without populating
R20; second preference is that user is not able to save workbook
without populating the cell. Any help?

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Data validation to force cell population

asayther,

You could use the change and selection change events to force an entry in cell R20. Copy the code
below, right-click the sheet tab, select "View Code", and paste in the window that appears.

This assumes that your list is stored in a named range myList.

HTH,
Bernie
MS Excel MVP

Dim ForceChange As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myNum As Long

If Intersect(Range("B20,R20"), Target) Is Nothing Then Exit Sub
On Error GoTo NotInList
myNum = Application.Match(Range("B20").Value, Range("myList"), False)
If Range("R20").Value = "" Then
ForceChange = True
Else
ForceChange = False
End If
Exit Sub

NotInList:
ForceChange = False

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not ForceChange Or Target.Address = "$R$20" Then Exit Sub
Application.EnableEvents = False
Range("R20").Select
MsgBox "Please enter a value in cell R20." & Chr(10) & _
"You have a value in B20, and you need one here."
If Range("R20").Value < "" Then
ForceChange = False
Else
ForceChange = True
End If
Application.EnableEvents = True

End Sub


wrote in message oups.com...
I am trying to force users to populate a cell (R20) with information
if cell (B20) equals a value off of a list. My first preference is
that the user is not be able to leave the row (20) without populating
R20; second preference is that user is not able to save workbook
without populating the cell. Any help?



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
Cell References [email protected] Excel Discussion (Misc queries) 2 November 15th 06 11:37 PM
data validation and cell protection jerrystan Excel Discussion (Misc queries) 0 January 19th 06 06:58 PM
Excel Macro to Copy & Paste [email protected] Excel Worksheet Functions 0 December 1st 05 01:56 PM
Help PLEASE! Not sure what answer is: Match? Index? Other? baz Excel Worksheet Functions 7 September 3rd 05 03:47 PM
6 Data Validation lists depending on 1 cell value beel Excel Discussion (Misc queries) 9 June 10th 05 07:34 PM


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