+ Reply to Thread
Results 1 to 5 of 5

How can a macro enter data in a protected Table cell?

  1. #1
    Registered User
    Join Date
    05-30-2014
    Location
    Lima, Peru
    Posts
    31

    Thumbs up How can a macro enter data in a protected Table cell?

    I'm using this code to set a time-stamp in Table1 Column A2:A601, the column is protected. When i enter data in column B2:B601, the macro enters the time-stamp. However, if the sheet is protected (no password used) the macro throws an error. How can the macro be modified to function with the sheet Protected (no password)?

    HTML Code: 
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rCell As Range
            
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
        Application.EnableEvents = False
        For Each rCell In Intersect(Target, Range("B:B"))
            If rCell <> "" Then
                Range("A" & rCell.Row).Value = Format(Now, "hh:mm:ss")
            Else
                Range("A" & rCell.Row).Clear
            End If
        Next rCell
        Application.EnableEvents = True
    End If
    
    End Sub
    Attached Files Attached Files
    Last edited by Mr.GfCs; 03-31-2016 at 06:03 PM. Reason: added file

  2. #2
    Registered User
    Join Date
    05-30-2014
    Location
    Lima, Peru
    Posts
    31

    Re: How do I allow a macro to enter data in a protected Table cell?

    I've added the spreadsheet to the post

  3. #3
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How can a macro enter data in a protected Table cell?

    This will test to see if the sheet is protected and return the sheet to the protection state it starts with. Assuming no password:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    05-30-2014
    Location
    Lima, Peru
    Posts
    31

    Re: How can a macro enter data in a protected Table cell?

    Yes, that did it. Thanks again JBeaucaire. I'm an absolute novice when it comes to Excel formulas as I've never used it much. When I search for ways to do what I want, sometimes I understand it, mostly I don't. But I do try to resolve the issues before posting on this forum....

    Thanks again.

  5. #5
    Administrator JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How can a macro enter data in a protected Table cell?

    Never apologize for asking for help on a forum dedicated to helping.
    Glad to be of assistance. Pay it forward.

+ 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. No Cell Movement after Pressing Enter with this macro I'm using on a protected sheet
    By Janet_824 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2016, 02:59 PM
  2. Replies: 4
    Last Post: 04-06-2014, 04:44 PM
  3. Replies: 3
    Last Post: 10-23-2012, 04:42 AM
  4. [SOLVED] Can a macro for multiple worksheets enter a password for protected sheets
    By missmea2005 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 08:12 AM
  5. Tab/Enter key moves to next available cell in protected worksheet
    By LMSCHIER in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-19-2005, 06:18 AM
  6. [SOLVED] Tab/Enter key moves to next available cell in protected worksheet
    By LMSCHIER in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-19-2005, 02:05 AM
  7. Replies: 1
    Last Post: 01-17-2005, 08:06 PM

Tags for this Thread

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