Bonjour
Voila une macro que je tente d'utiliser dans un fichier partagé:
Private Sub CommandButton1_Click()
If ActiveWorkbook.MultiUserEditing Then
Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True
End If
Dim cellule As Range, trouve As Range, suite As Range
Set cellule = Range("B22") 'valeur à chercher
With Sheets("codes_créés")
Set suite = .Range("A1").End(xlDown).Offset(1, 0) 'identifie la prochaine cellule vide
Set trouve = .Columns("A").Find(cellule.Value, LookIn:=xlFormulas, lookat:=xlWhole) 'cherche B4 en colonne A
If trouve Is Nothing Then 'si pas trouvé
suite.Value = cellule.Value
Else: MsgBox "Attention, code existant!", vbInformation, "Codification automatique"
Exit Sub
End If
End With
If Not ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, _
accessMode:=xlShared
End If
Range("B22").Copy
End Sub
Pour cela je désactive le partage avant son exécution:
If ActiveWorkbook.MultiUserEditing Then
Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True
End If
Ensuite j'essai de réactiver le partage:
If Not ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, _
accessMode:=xlShared
End If
Premier problème excel me demande si je veux écraser le fichier. Moi je voudrais qu'il l'écrase sans ma confirmation.
Deuxième problème quand mon "code existe" je sort de l'exécution de la macro:
Else: MsgBox "Attention, code existant!", vbInformation, "Codification automatique"
Exit Sub
A la place de sortir j'aimerais réactiver le partage en sauvegardant et sans message d'alerte.
Quelqu'un peut-il m'aider SVP
Merci
Voila une macro que je tente d'utiliser dans un fichier partagé:
Private Sub CommandButton1_Click()
If ActiveWorkbook.MultiUserEditing Then
Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True
End If
Dim cellule As Range, trouve As Range, suite As Range
Set cellule = Range("B22") 'valeur à chercher
With Sheets("codes_créés")
Set suite = .Range("A1").End(xlDown).Offset(1, 0) 'identifie la prochaine cellule vide
Set trouve = .Columns("A").Find(cellule.Value, LookIn:=xlFormulas, lookat:=xlWhole) 'cherche B4 en colonne A
If trouve Is Nothing Then 'si pas trouvé
suite.Value = cellule.Value
Else: MsgBox "Attention, code existant!", vbInformation, "Codification automatique"
Exit Sub
End If
End With
If Not ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, _
accessMode:=xlShared
End If
Range("B22").Copy
End Sub
Pour cela je désactive le partage avant son exécution:
If ActiveWorkbook.MultiUserEditing Then
Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True
End If
Ensuite j'essai de réactiver le partage:
If Not ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, _
accessMode:=xlShared
End If
Premier problème excel me demande si je veux écraser le fichier. Moi je voudrais qu'il l'écrase sans ma confirmation.
Deuxième problème quand mon "code existe" je sort de l'exécution de la macro:
Else: MsgBox "Attention, code existant!", vbInformation, "Codification automatique"
Exit Sub
A la place de sortir j'aimerais réactiver le partage en sauvegardant et sans message d'alerte.
Quelqu'un peut-il m'aider SVP
Merci