+ Reply to Thread
Results 1 to 4 of 4

Using Macros With Sheet Protection

  1. #1
    Registered User
    Join Date
    08-29-2013
    Location
    Kentucky
    MS-Off Ver
    Excel 2010
    Posts
    3

    Using Macros With Sheet Protection

    Hi, I'm trying to use a macro to copy and then paste the values and formatting from one sheet to another. However, I have several formulas in the initial sheet that I am copying, that I do not want to be compromised. I have tried to record a unprotect, copy, paste, protect again, type formula, but that does not seem to work. Could anyone help with the proper VBA code needed to accomplish this? Here is my current VBA code for the macro:

    Sub Complete()
    '
    ' Complete Macro
    '

    '
    ActiveSheet.Unprotect
    Range("A4:E30").Select
    Selection.Copy
    Sheets("Raw Input Answer History").Select
    Range("A29").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Loan Summary").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Loan Compliance History Listing").Select
    Range("A23").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Input Loan Info").Select
    Range("B4").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Range("B5").Select
    Selection.ClearContents
    Range("B6").Select
    Selection.ClearContents
    Range("B7").Select
    Selection.ClearContents
    Range("B8").Select
    Selection.ClearContents
    Range("B9").Select
    Selection.ClearContents
    Range("B10").Select
    Selection.ClearContents
    Range("B11").Select
    Selection.ClearContents
    Range("B12").Select
    Selection.ClearContents
    Range("C14:E17").Select
    Selection.ClearContents
    Range("C18").Select
    Selection.ClearContents
    Range("D18").Select
    Selection.ClearContents
    Range("E18").Select
    Selection.ClearContents
    Range("C19").Select
    Selection.ClearContents
    Range("D19").Select
    Selection.ClearContents
    Range("D20").Select
    Selection.ClearContents
    Range("C20").Select
    Selection.ClearContents
    Range("D21").Select
    Selection.ClearContents
    Range("C21").Select
    Selection.ClearContents
    Range("D22").Select
    Selection.ClearContents
    Range("C22").Select
    Selection.ClearContents
    Range("C25").Select
    Selection.ClearContents
    Range("D25").Select
    Selection.ClearContents
    Range("D26").Select
    Selection.ClearContents
    Range("C26").Select
    Selection.ClearContents
    Range("E26").Select
    Selection.ClearContents
    Range("D27").Select
    Selection.ClearContents
    Range("C27").Select
    Selection.ClearContents
    Range("C28").Select
    Selection.ClearContents
    Range("D28").Select
    Selection.ClearContents
    Range("E28").Select
    Selection.ClearContents
    Range("D29").Select
    Selection.ClearContents
    Range("C29").Select
    Selection.ClearContents
    Range("C30").Select
    Selection.ClearContents
    Range("D30").Select
    Selection.ClearContents
    Range("E30").Select
    Selection.ClearContents
    Range("B4").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    End Sub



    I'm sure this is quite easy, but I am just getting started with VBA and am not exactly sure where to put certain strings yet. Thanks in advance for your help.

  2. #2
    Registered User
    Join Date
    08-29-2013
    Location
    Kentucky
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Using Macros With Sheet Protection

    Bump. Still no solution. Anybody?

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Using Macros With Sheet Protection

    Hi, wku0515,

    certainly not the answer that you expected.


    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    ===
    If your question has not been answered within a day, consider adding another post with any additional information you believe is relevant. If you think your post is good as is, just reply to your own thread with the words "Bump no response", which will bring it to the top of the forum.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    08-29-2013
    Location
    Kentucky
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Using Macros With Sheet Protection

    Please Login or Register  to view this content.

+ 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. Excel 2010 - Copying sheet with protection manually, protection stays... not with VBA
    By AdamParker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-02-2012, 12:38 PM
  2. Macros with protection problem
    By rallyman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2007, 07:47 PM
  3. macros and protection
    By SYBS in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-24-2006, 02:00 PM
  4. [SOLVED] Macros and protection
    By scott45 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-01-2005, 03:30 PM
  5. [SOLVED] have macros complete and enter passwords for sheet protection.
    By nick-ipswich in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2005, 01:07 AM

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