Probleme protection feuille
Bonjour voila mon problème : sur mon Excel j'ai 2 feuille menu et stock
sur menu j'ai 2 bouton un fiche de stock pour voir se qu' il y a au stock et l'autre il souligne en verte se que je cherche .
Se que je cherche sais de protéger contre l'écriture la feuille stock le bouton fiche de stock fonctionne bien mais le bouton recherche non
pouvez- vous m'aider svp merci
Bonjour Buesst
Comme ta feuille est protégée, il te faut la déprotéger avant toute action dessus
Exemple
Private Sub CommandButton1_Click()
' Rechercher
Dim Cel As Range
Dim Recherche As String, Depart As String
Dim Colonne As Integer
If Me.TextBox1 = "" And Me.TextBox2 = "" Then
MsgBox "Veuillez indiquer soit un repère soit une référence"
ElseIf Me.TextBox1 <> "" And Me.TextBox2 <> "" Then
MsgBox "Veuillez choisir soit un repère SOIT une référence"
Else
Application.ScreenUpdating = False
Recherche = IIf(Me.TextBox1 <> "", Me.TextBox1, Me.TextBox2)
Colonne = IIf(Me.TextBox1 <> "", 2, 3)
With Sheets("Stock")
.Unprotect
.Range("A2:J" & .Range("A" & Rows.Count).End(xlUp).Row).Interior.ColorIndex = xlNone
Set Cel = .Columns(Colonne).Find(What:=Recherche, LookIn:=xlValues, LookAt:=xlPart)
If Not Cel Is Nothing Then
.Select
Depart = Cel.Address
Do
If Cel.Row > 1 Then
.Range("A" & Cel.Row & ":J" & Cel.Row).Interior.ColorIndex = 4
End If
Set Cel = .Columns(Colonne).FindNext(Cel)
Loop While Depart <> Cel.Address
End If
.Protect
End With
End If
End Sub
Partout ou ça bug, il faudra faire la même chose
A+
un grand merci a toi sais super
vous pouvais encore m'aider j'ai un code et je sais pas comment ajouter une 2 éme ligne la j'ai linge 2 et faut que j'ajoute une nouvelle
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
Range("B2:B203").Interior.ColorIndex = 2
ListBox1.Clear
If TextBox1 <> "" Then
For ligne = 2 To 203
If Cells(ligne, 2) Like "*" & TextBox1 & "*" Then
Cells(ligne, 2).Interior.ColorIndex = 43
ListBox1.AddItem Cells(ligne, 2)
End If
Next
End If
End Sub
Re,
Private Sub TextBox1_Change()
ActiveSheet.Unprotect
Application.ScreenUpdating = False
Range("B2:B203").Interior.ColorIndex = 2
ListBox1.Clear
If TextBox1 <> "" Then
For ligne = 2 To 203
If Cells(ligne, 2) Like "*" & TextBox1 & "*" Then
Cells(ligne, 2).Interior.ColorIndex = 43
ListBox1.AddItem Cells(ligne, 2)
End If
Next
End If
ActiveSheet.Protect
End Sub
Voilà
merci mais je me suis mal exprimer le but sais que quand j'écrit un mot le mot en personne s'affiche ca sais bon mais a la suite j'aimerai que la zone s'affiche aussi