Prevent User from Going Past a Certain Cell

G

Guest

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
 
J

Jake Marx

Hi Paige,
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]
 
N

NickHK

Paige,
How about:

With ThisWorkbook.Worksheets(YourWS)
.Unprotect
.ScrollArea = OKRangeAs string
.EnableSelection = xlUnlockedCells
.Protect , , , , True
End With

NickHK
 
G

Guest

Jake, I used your code last night and it worked - thanks! Nick, will try
yours today also.....thanks so much to both of you for taking the time to
respond.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top