Can I conditionally lock/unlock some cells

K

King George John

Hi

I am making a journal on a spread sheet whereby each row is a successive
date.

I would like to make it so that the user can ONLY change the current row
(date = TODAY). I figured out how to use conditional formatting to make
the current date row a different color but I would like to go further and
make it so the user can only change the current line.

Can this be done?

How?

Thanks in advance
 
F

Frank Kabel

Hi,

you can use 'Data - Validation' and check if the date in one cell is
equal to TODAY()
Frank
 
D

Dave Peterson

Another way is to use a macro that unprotects the worksheet, locks all the
cells, unlocks the cells that are on that one row (matching today's date), and
the reprotect the workbook.

Option Explicit
Sub auto_open()

Dim res As Variant
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

With wks
.Unprotect Password:="hi"
.Cells.Locked = True

res = Application.Match(CLng(Date), .Range("a:a"), 0)
If IsError(res) Then
MsgBox "worksheet protected--today wasn't found"
Else
.Cells(res, "B").Resize(1, .Columns.Count - 1).Cells.Locked = False
Application.Goto .Cells(res, "a"), scroll:=True
.Cells(res, "B").Select
End If

.Protect Password:="hi"
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

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