Consulting

Results 1 to 7 of 7

Thread: a quick hi added with question

  1. #1
    VBAX Regular
    Joined
    Nov 2008
    Posts
    54
    Location

    a quick hi added with question

    Hello,

    As every1 else started once ... so do i now
    I did use the forums alot before but i thought now it the time to say thank you to every1 for the loads of info that can be found here!
    Im still searching & reading alot but one question thats keeping me busy:

    I have a protected excel sheet (because i want end users not to change worksheet names else my macro to make a new sheet stops working) but now i cant copy the sheet anymore with my macro. So i have to choose:
    unprotect sheet and risk ppl renaming the sheets or protect sheet but impossible to copy the sheet without removing the protection 1st.
    Its probs kinda basic for most forum users but im still a starter and spent last 8 hours on the sheet and now i run into this lol.
    Thx 4 any ideas in advance!

    Ev

  2. #2
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    Use Workbook.Unprotect ("MyPassword")
    or Worksheet.Unprotect ("MyPassword")
    to remove password protection momentarily, then use
    Workbook.Protect ("MyPassword")
    or Worksheet.Protect ("MyPassword")
    to protect again.

  3. #3
    VBAX Regular
    Joined
    Nov 2008
    Posts
    54
    Location
    Quote Originally Posted by nst1107
    Use Workbook.Unprotect ("MyPassword")
    or Worksheet.Unprotect ("MyPassword")
    to remove password protection momentarily, then use
    Workbook.Protect ("MyPassword")
    or Worksheet.Protect ("MyPassword")
    to protect again.
    Thats a quick reply . Ok thx alot. im gonna try fit it in there somewere lol

    Ev

    Edit: just tried. This is the code:

    Workbook.unprotect ("MyPassword")
    Sheets("LOGSHEET(1)").Select
    Sheets("LOGSHEET(1)").Copy Before:=Sheets(1)

    Workbook.protect ("MyPassword")

    Gives error code "424", Object required

    Hmm ill have me thoughts over it what went wrong lol

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings Eville,

    Can you post the code you are using (the sub or function) thus far?

    Mark

  5. #5
    VBAX Regular
    Joined
    Nov 2008
    Posts
    54
    Location
    Quote Originally Posted by GTO
    Greetings Eville,

    Can you post the code you are using (the sub or function) thus far?

    Mark
    Dont expect much pls, im only a starter & still need loads and loads to learn ><
    So far the code to copy the original sheet is:

    Sub Logsheet()
    '
    Workbook.unprotect ("MyPassword")

    Sheets("LOGSHEET(1)").Select
    Sheets("LOGSHEET(1)").Copy Before:=Sheets(1)

    Workbook.protect ("MyPassword")

    End Sub

    As you can see its for a logsheet, to keep production results and when its full (7 coils) we start a next sheet with this above function.
    I think i have 2 put the workbook protect and unprotect in a different way but still searching how 2 do so. So looks dumb maybe ... not sure :P

    Ev

  6. #6
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    I'm sorry. This is the exact verbage you would use. Insert your real password where it says "MyPassword":
    [vba]
    Sub Logsheet()
    '
    ThisWorkbook.Unprotect ("MyPassword")
    Sheets("LOGSHEET(1)").Select
    Sheets("LOGSHEET(1)").Copy Before:=Sheets(1)

    ThisWorkbook.Protect ("MyPassword")
    End Sub
    [/vba]

  7. #7
    VBAX Regular
    Joined
    Nov 2008
    Posts
    54
    Location
    Quote Originally Posted by nst1107
    I'm sorry. This is the exact verbage you would use. Insert your real password where it says "MyPassword":
    [vba]
    Sub Logsheet()
    '
    ThisWorkbook.Unprotect ("MyPassword")
    Sheets("LOGSHEET(1)").Select
    Sheets("LOGSHEET(1)").Copy Before:=Sheets(1)

    ThisWorkbook.Protect ("MyPassword")
    End Sub
    [/vba]
    Ty very much, its working now also its working on the next sheets & when i forget to protect the sheet and copy a sheet it automatically protects it. Thx loads
    I should have known its ThisWorkbook and not Workbook

    Ev

Posting Permissions

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