Consulting

Results 1 to 2 of 2

Thread: Solved: Unprotect Sheets while looping through files

  1. #1

    Solved: Unprotect Sheets while looping through files

    I have a project where I loop through multiple files in a folder, copy data out of the folder and put it in a "master" folder. I've been using test files and have the code working, however, I've just been informed that the cells that I will be copying are protected. My question is if my code doesn't actually "select" the data, do I need to unprotect the sheets. If I do need to unprotect the sheets, how do I do it? The password for all of the worksheets is the same.

    As an aside, I just want to thank everyone who adds their expertise to this site. I am learning and being able to search one site for answers has really helped me.

    Kathyb

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Kathy,
    I don't think you need to unprotect to copy data.

    If you need to make changes, then something like
    [VBA]
    Sheets(1).Unprotect Password:="PW"
    Sheets(1).Cells.Copy Sheets(2).Range("A1")
    Sheets(1).Protect Password:="PW"

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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