• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Code toepassen op geblokkeerde cellen in een beveiligde sheet

Status
Niet open voor verdere reacties.

Scallebe

Gebruiker
Lid geworden
29 okt 2014
Berichten
528
Goede avond Helpmij-ers

Met een userform vul ik 10 lottogetallen in op mijn sheet met volgende code :

Code:
Private Sub cmdNummersUpdate_Click()
      
      Dim Lotto10Spaarkas As Worksheet
      Dim FoundCell As Range
      Dim Search As String
      Dim eRow As Long

     Set wsLotto10Spaarkas = ActiveSheet
     With wsLotto10Spaarkas
         eRow = ActiveCell.Row

         If txt1 <> "" Then .Cells(eRow, 4).Value = FormatNumber(txt1.Value, "0")
         If txt2 <> "" Then .Cells(eRow, 5).Value = FormatNumber(txt2.Value, "0")
         If txt3 <> "" Then .Cells(eRow, 6).Value = FormatNumber(txt3.Value, "0")
         If txt4 <> "" Then .Cells(eRow, 7).Value = FormatNumber(txt4.Value, "0")
         If txt5 <> "" Then .Cells(eRow, 8).Value = FormatNumber(txt5.Value, "0")
         If txt6 <> "" Then .Cells(eRow, 9).Value = FormatNumber(txt6.Value, "0")
         If txt7 <> "" Then .Cells(eRow, 10).Value = FormatNumber(txt7.Value, "0")
         If txt8 <> "" Then .Cells(eRow, 11).Value = FormatNumber(txt8.Value, "0")
         If txt9 <> "" Then .Cells(eRow, 12).Value = FormatNumber(txt9.Value, "0")
         If txt10 <> "" Then .Cells(eRow, 13).Value = FormatNumber(txt10.Value, "0")
     End With
     Unload Me
End Sub


De cellen in mijn sheet zijn echter geblokkeerd en de sheet is paswoord beveiligd.

Hoe kan ik met vba die beveiliging en blokkade tijdelijk opheffen om de cellen te kunnen invullen?


Bedankt


Pascal
 
Zoiets:
Code:
Private Sub cmdNummersUpdate_Click()
      
      Dim Lotto10Spaarkas As Worksheet
      Dim FoundCell As Range
      Dim Search As String
      Dim eRow As Long

     Set wsLotto10Spaarkas = ActiveSheet
     With wsLotto10Spaarkas
         [COLOR="#FF0000"].Unprotect "HetWachtwoord"[/COLOR]
         eRow = ActiveCell.Row
         
         If txt1 <> "" Then .Cells(eRow, 4).Value = FormatNumber(txt1.Value, "0")
         If txt2 <> "" Then .Cells(eRow, 5).Value = FormatNumber(txt2.Value, "0")
         If txt3 <> "" Then .Cells(eRow, 6).Value = FormatNumber(txt3.Value, "0")
         If txt4 <> "" Then .Cells(eRow, 7).Value = FormatNumber(txt4.Value, "0")
         If txt5 <> "" Then .Cells(eRow, 8).Value = FormatNumber(txt5.Value, "0")
         If txt6 <> "" Then .Cells(eRow, 9).Value = FormatNumber(txt6.Value, "0")
         If txt7 <> "" Then .Cells(eRow, 10).Value = FormatNumber(txt7.Value, "0")
         If txt8 <> "" Then .Cells(eRow, 11).Value = FormatNumber(txt8.Value, "0")
         If txt9 <> "" Then .Cells(eRow, 12).Value = FormatNumber(txt9.Value, "0")
         If txt10 <> "" Then .Cells(eRow, 13).Value = FormatNumber(txt10.Value, "0")
         [COLOR="#FF0000"].Protect "HetWachtwoord"[/COLOR]
     End With
     Unload Me
End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan