+ Reply to Thread
Results 1 to 2 of 2

Macro does not work when sheet is protected??

  1. #1
    Registered User
    Join Date
    07-11-2011
    Location
    Delhi, India
    MS-Off Ver
    Excel 2007
    Posts
    26

    Macro does not work when sheet is protected??

    Hi All, Hi tigeravatar

    Below is the code of one of the macros, the problem is it does now work when the work sheet is passowrd protected?? can somebody help? Password to unlock the sheet is "international". I want the macro to open the sheet paste the details and then again lock the sheet...somebody please help?



    Sub btn_Submit_Click()

    Dim wsReq As Worksheet 'Request worksheet (Request Form)
    Dim wsSch As Worksheet 'Schedule worksheet (Only to be seen by Admin)
    Dim rngFindName As Range
    Dim rIndex As Long
    Dim strName As String

    Set wsReq = ActiveSheet
    Set wsSch = Sheets("Only to be seen by Admin")

    With wsReq
    If Trim(.Range("C7").Value) = vbNullString Then
    .Range("C7:D8").Select
    MsgBox "No employee code provided.", , "Shift Request Error"
    Exit Sub
    End If

    Set rngFindName = wsSch.Columns("C").Find(.Range("C7").Value, , , xlWhole)
    If Not rngFindName Is Nothing Then
    rIndex = rngFindName.Row
    strName = Trim(.Range("I6").Value)
    If strName = vbNullString Then strName = "(-)"
    wsSch.Cells(rIndex, Columns.Count).End(xlToLeft).Offset(, 1).Resize(, 6).Value = _
    Array(.Range("C10").Text, .Range("F10").Text, .Range("C16").Value, .Range("C19").Value, strName, .Range("C23").Value)
    .Range("C4:E5,C7:D8,C10:D11,C13:D14,C16:D17,C19:D20,C23:L26,F10:G11,I6:K7,J10:K11,J14:K15").ClearContents
    .Range("C4:E5").Select
    Else
    .Range("C7:D8").Select
    MsgBox "Employee Code [" & .Range("C7").Value & "] not found.", , "Shift Request Error"
    End If
    End With

    End Sub

    cheers and thanks

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Macro does not work when sheet is protected??

    Welcome to the forum.

    Guess you didn't read the forum rules or you would know that you are *REQUIRED* to use code tags any time you post VBA code.
    Please edit your post to add the tags then someone will help.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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