#1   Report Post  
HuckinD
 
Posts: n/a
Default Write once cells


Is there any way that I can write a macro or code for a quiz sheet I
have made.
I want my pupils to be able to type into the cell but would like it
lock the cell after they have typed something in so effectively I can
use it as a test but the first answer is the one that counts.
Somebody suggested that I rightclick on the workbook tab and then use
the view code function, but I know nothing about computer code and
would not know what to write in the boxes
Any ideas would be greatly appreciated.
Thanks
Dave


--
HuckinD
  #2   Report Post  
pdberger
 
Posts: n/a
Default Write once cells

I'm confident you can do this by setting a 'protection' value using the
programming language called VBA. However, it's beyond my rather paltry
skills. You should address the question to the 'programming' section on this
web page, where the gurus who know that stuff live.

"HuckinD" wrote:


Is there any way that I can write a macro or code for a quiz sheet I
have made.
I want my pupils to be able to type into the cell but would like it
lock the cell after they have typed something in so effectively I can
use it as a test but the first answer is the one that counts.
Somebody suggested that I rightclick on the workbook tab and then use
the view code function, but I know nothing about computer code and
would not know what to write in the boxes
Any ideas would be greatly appreciated.
Thanks
Dave


--
HuckinD

  #3   Report Post  
Richard Buttrey
 
Posts: n/a
Default Write once cells

On Sun, 16 Oct 2005 21:16:48 +0000, HuckinD
wrote:


Is there any way that I can write a macro or code for a quiz sheet I
have made.
I want my pupils to be able to type into the cell but would like it
lock the cell after they have typed something in so effectively I can
use it as a test but the first answer is the one that counts.
Somebody suggested that I rightclick on the workbook tab and then use
the view code function, but I know nothing about computer code and
would not know what to write in the boxes
Any ideas would be greatly appreciated.
Thanks
Dave



How foolproof would you want this to be? To set protection you need to
set a password. If you want to have a macro temporarily switch off
protection whilst the user enters a value, I guess you're going to
have to have the password stored in the macro, and anyone who knew how
to find their way around VBA could discover the password. That said
you could sort of hide the password in a complex algorithm rather than
a straightforward piece of text.

If this rudimentary security is acceptable, I think the approach I'd
adopt would be to name all the cells where you want the answers. e.g.
"Ans1", "Ans2" etc. and have the macro store in the comment behind the
cell a flag to show it had been accessed.

The macro would respond to the SheetChange event when an answer cell
is selected, and first test to see if the comment flag has been set.
If not then allow an answer and set the flag.

If this is the sort of thing that you want, post back and I'll try and
suggest some code. How many questions would you want to handle and are
there any other design features required?

Rgds
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default Write once cells

Here is one way.

Add this code to the worksheet in question (change the range in
RANGE_MONITOR to your range)

Private Sub Worksheet_Change(ByVal Target As Range)
Const RANGE_MONITOR As String = "H1:H10"
Dim sPW As String
On Error GoTo ws_exit:
sPW = Evaluate(ThisWorkbook.Names("___pw").RefersTo)
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(RANGE_MONITOR)) Is Nothing Then
With Target
Me.Unprotect Password:=sPW
.Locked = True
Me.Protect Password:=sPW
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.

Then run this code on the worksheet, but delete it afterwards, don';t leave
it around

Sub SetupSheet()
ActiveSheet.Cells.Locked = False
ActiveWorkbook.Names.Add Name:="___pw", RefersTo:="ABCD"
ActiveWorkbook.Names("___pw").Visible = False
ActiveSheet.Protect Password:="ABCD"
End Sub

Change the password to suit.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"HuckinD" wrote in message
...

Is there any way that I can write a macro or code for a quiz sheet I
have made.
I want my pupils to be able to type into the cell but would like it
lock the cell after they have typed something in so effectively I can
use it as a test but the first answer is the one that counts.
Somebody suggested that I rightclick on the workbook tab and then use
the view code function, but I know nothing about computer code and
would not know what to write in the boxes
Any ideas would be greatly appreciated.
Thanks
Dave


--
HuckinD



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
how do i protect cells in a shared worksheet Debi Excel Discussion (Misc queries) 3 September 30th 05 11:15 PM
Display first, second, etc Nonblank Cells in a Range Jeremy N. Excel Worksheet Functions 12 September 25th 05 01:47 PM
How do you write 2 lines of text in 1 cell rather than use 2 cells !!!help!!! Excel Discussion (Misc queries) 5 September 20th 05 06:05 PM
Using SUM function with #N/A in some cells Jeeper Excel Worksheet Functions 5 June 10th 05 06:28 AM
Can I count how many grey-filled cells are in a row ? AnthonyG Excel Worksheet Functions 1 February 4th 05 10:08 AM


All times are GMT +1. The time now is 06:09 AM.

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"