+ Reply to Thread
Results 1 to 3 of 3

Unprotect not working

  1. #1
    Registered User
    Join Date
    03-31-2006
    Posts
    24

    Unprotect not working

    Does any one know why Unprotect is not working on the below code for the Active Sheet.

    Sub custlistcombobox()

    ActiveSheet.unprotect

    Dim FirstAddress As String
    Dim c As Range

    With Worksheets("Customer List").Range("A2:A15501")
    Set c = .Find(what:=Range("C137"), LookIn:=xlValues)
    If Not c Is Nothing Then
    FirstAddress = c.Address
    Do
    With ActiveSheet.Range("F105")

    .Value = c.Offset(, 1) ' Name
    .Offset(1, -3) = c.Offset(, 2) ' Phone
    .Offset(1, 0) = c.Offset(, 3) ' Fax
    .Offset(2, -3) = c.Offset(, 4) ' Email
    .Offset(4, -3) = c.Offset(, 7) ' PST
    .Offset(4, 0) = c.Offset(, 8) ' GST
    .Offset(23, -2) = c.Offset(, 13) 'Customer Comments

    End With
    Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> FirstAddress
    End If
    End With

    ActiveSheet.Protect

    End Sub

  2. #2
    Vasant Nanavati
    Guest

    Re: Unprotect not working

    If there is a worksheet protection password, you need to supply it to the
    macro, e.g.:

    ActiveSheet.Unprotect "sesame"


    "bobwilson" <bobwilson.25paez_1144088102.9016@excelforum-nospam.com> wrote
    in message news:bobwilson.25paez_1144088102.9016@excelforum-nospam.com...
    >
    > Does any one know why Unprotect is not working on the below code for the
    > Active Sheet.
    >
    > Sub custlistcombobox()
    >
    > ActiveSheet.unprotect
    >
    > Dim FirstAddress As String
    > Dim c As Range
    >
    > With Worksheets("Customer List").Range("A2:A15501")
    > Set c = .Find(what:=Range("C137"), LookIn:=xlValues)
    > If Not c Is Nothing Then
    > FirstAddress = c.Address
    > Do
    > With ActiveSheet.Range("F105")
    >
    > Value = c.Offset(, 1) ' Name
    > Offset(1, -3) = c.Offset(, 2) ' Phone
    > Offset(1, 0) = c.Offset(, 3) ' Fax
    > Offset(2, -3) = c.Offset(, 4) ' Email
    > Offset(4, -3) = c.Offset(, 7) ' PST
    > Offset(4, 0) = c.Offset(, 8) ' GST
    > Offset(23, -2) = c.Offset(, 13) 'Customer Comments
    >
    > End With
    > Set c = .FindNext(c)
    > Loop While Not c Is Nothing And c.Address <> FirstAddress
    > End If
    > End With
    >
    > ActiveSheet.Protect
    >
    > End Sub
    >
    >
    > --
    > bobwilson
    > ------------------------------------------------------------------------
    > bobwilson's Profile:
    > http://www.excelforum.com/member.php...o&userid=33046
    > View this thread: http://www.excelforum.com/showthread...hreadid=529300
    >




  3. #3
    Registered User
    Join Date
    03-31-2006
    Posts
    24
    I don't use passwords. In all my Macros I Unprotect the sheet at the beginning of the macro and then Protect the sheet at the end. For some reason this macro does not want to unprotect the activesheet.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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