sid
sid

Reputation: 129

Application-defined or object-defined error with Format function

My cell is locked and I am filling the cell with data on Worksheet_Change event of a drop-down: Format(Date, "mm-dd-yyyy").

I am getting following error :: Run-time error '1004': Application-defined or object-defined error

I do not want to unlock the field as it is to be non-editable.

I also do understand that it is giving the error just because the cell is locked and it needs to perform the operation: Format(Date, "mm-dd-yyyy")..

What options do I have to make it working without unlocking the cell?

Upvotes: 0

Views: 548

Answers (1)

Scott Holtzman
Scott Holtzman

Reputation: 27239

Unlock the sheet, then make changes as needed, then lock again.

Me.Unprotect "pwd"
Me.Range("A1").Value = Format(Date,"mm-dd-yyyy")
Me.Protect "pwd"

Upvotes: 1

Related Questions