Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error when changing format of unprotected cell of a protected sheet

Status
Not open for further replies.

frankjet

Instructor
Aug 21, 2001
1
NL
Via VBA I change the formatting of a cell. This cell is unprotected.
When I protect (Tools - protect) the sheet, I get an error when I start the VBA-code (macro).

Some code I wrote:
ActiveCell.Offset(1, 0).Activate
ActiveCell.Formula = Now()
Selection.NumberFormat = "h:mm:ss"

The last line gives the problem.

Is there a possibility to change the default formatting of the formula now(). It has to be "h:mm:ss"

Thanks in advance.
 
Consider:

I formatted [A1] as unlocked
All other cells are locked (default)
I protected the Worksheet
I ran this line of code

[A1].Value = Format(Now(), "h:mm:ss")


Worked with no error

If I'm way off on this email me at
drat@mediaone.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top