Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:07:06+00:00 2026-06-13T16:07:06+00:00

When I first open my workbook I call this function to protect specific cell

  • 0

When I first open my workbook I call this function to protect specific cell ranges and cells from the user:

' Sets protection on sheet
Public Sub LockCells_TXN_CLIENT_ORDER_ENTRY()
  ActiveSheet.Unprotect Password:="abc"
  ActiveSheet.Cells.Locked = False
  ' Lock some cells here
  ActiveSheet.Protect Password:="abc"
End Sub

However, upon calling the following Subrouting to clear data from a range of rows:

Private Sub ClearData_Click()
  ' Declare some variables

  For currentRow = ActiveSheet.Range("STATUS_FIELDS").Row To totalRows
    ActiveSheet.Cells(currentRow, ActiveSheet.Range("STATUS_FIELDS").Column).Resize(1, 14).Clear
  Next currentRow
End Sub

Cells that were not specified to be protected now becomes protected and these cells are the exact same cells that the ClearData_Click() function affected.

Could someone please explain to me why this happens and how to avoid this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:07:07+00:00Added an answer on June 13, 2026 at 4:07 pm

    Your use of .Clear is causing the problem.

    Either use .ClearContents instead, or re-set the locked property after you clear the range.

    .Clear clears the entire object, including the part where you set its locked property to false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm printing the first line from a file: with open(path,r,encoding='utf8') as f: for i,
when u first open up iphone, all the app are layout in a grid
I have some problems with my first Open Graph custom action: I've created a
I traced an oracle process, and find it first open a file /etc/netconfig as
In the following code snippet, if I go to the first open parenthesis (
It does work but it doesn't replace the letters. First I open one file,
I've got some strange bug: when I open page first time in some browser
I have two pages. First one we open with $_POST variables in its url,
The first stage that I load it always open properly as fullscreen. stage.setFullScreen(true); stage.setScene(login_scene);
First some background, I've written an open source .NET library, named Duplicitiy (on github.com),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.