View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Prevent User from Going Past a Certain Cell

Hi Paige,

Paige wrote:
I have a spreadsheet where the user has to answer yes or no to 4
questions, in cells C30, C31, C32, and C34. I do not want them to be
able to select any other unlocked cell in the spreadsheet AFTER C34
until/unless they have answered C30, C31, C32 and C34. Can someone
advise how to do this; have been struggling for awhile and my mind is
fried.....thanks...pc


This is a bit ugly, but it should work for you:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.Union(Target, Range("C30:C32"), _
Range("C34")).Cells.Count < 4 Then
'/ trying to select something else
If Application.CountA(Range("C30:C32,C34")) < 4 Then
MsgBox "You must answer all 4 questions to proceed."
Application.Goto Range("C30")
End If
End If
End Sub

This code must reside behind the worksheet containing the questions
(right-click sheet tab and select View Code, paste this code into the
resulting code pane).

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]