+ Reply to Thread
Results 1 to 3 of 3

Need help creating a macro to clear cells after a date, but the sheet is password protect

  1. #1
    Registered User
    Join Date
    07-22-2018
    Location
    Abu Dhabi
    MS-Off Ver
    Office 2016
    Posts
    9

    Need help creating a macro to clear cells after a date, but the sheet is password protect

    Hello,

    I need help creating a macro that will delete or clear a range of cells after a calendar date in a cell; however, the sheet is password protected so it will need to unlock the sheet before clearing the cells. I enclosed an example of a spreadsheet with the calendar date in cell 3A, but any spreadsheet could apply.

    Thank you!

    TC
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help creating a macro to clear cells after a date, but the sheet is password prot

    Right Click on the sheet name at the bottom of excel and select view code

    Paste this into the module that opens and close it. NB I have assumed that the password is Test

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    07-22-2018
    Location
    Abu Dhabi
    MS-Off Ver
    Office 2016
    Posts
    9

    Re: Need help creating a macro to clear cells after a date, but the sheet is password prot

    Hi mehmetcik,

    Thank you so much for the help, but the macro doesn't seem to work for a particular date. I tried several methods, but can't get the macro to delete based on a specific date. Any ideas?

    Private Sub Worksheet_Activate()
    If Range("A3").Value = 11 / 11 / 2019 Then
    ActiveSheet.Unprotect ("test")
    Range("B3:C12").Clear
    ActiveSheet.Protect ("test")
    End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro Code to individually password protect a sheet
    By Zano_1980 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2017, 11:43 AM
  2. Creating a macro to password protect each sheet
    By alex2damax in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2015, 01:37 AM
  3. [SOLVED] How to password protect only certain cells within a sheet
    By kevwilsondj in forum Excel General
    Replies: 3
    Last Post: 03-23-2015, 07:52 PM
  4. [SOLVED] Macro to filter and protect sheet with password
    By GregTheSquarePeg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2013, 05:42 AM
  5. Excel 2007 : VBA - Password Protect Sheet / certain cells
    By littlefoot in forum Excel General
    Replies: 2
    Last Post: 12-13-2011, 01:43 PM
  6. Replies: 3
    Last Post: 02-11-2009, 10:17 AM
  7. HOW DO I PROTECT VALUES WHEN CREATING CLEAR CONTENTS MACRO?
    By the holster in forum Excel General
    Replies: 1
    Last Post: 02-20-2006, 02:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1