Problème de séparateurs décimaux
Bonjour tout le monde,
J'étais venu solliciter votre aide il y a quelques temps concernant la mise en majuscule d'une plage dynamique :
https://forum.excel-pratique.com/post585404.html#p585404
Grâce à vous, j'ai pu avancer et quasiment finaliser mon code. Je vous en remercie. Après quelques utilisations, je me suis rendu compte d'un souci que je n'arrive pas à corriger.
Lorsque je souhaite rentrer des sommes avec des centimes (en colonne H), ma cellule passe en format texte et bien sûr le chiffre n'est plus reconnu et ma somme s'en trouve impactée.
Après quelques manipulations, je me suis rendu compte que cela provenait de la virgule.
J'ai donc essayé dans un premier temps de corriger à la volée le séparateur, mais je reste coincé.
Aussitôt que je rentre une nouvelle ligne, la mise à jour globale du tableau me remet ma somme en texte.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("$B:$H"), Range(Target.Address)) Is Nothing Then
Dim lignes As Integer, i, celluleACapitaliser
lignes = Cells(Rows.Count, 2).End(xlUp).Row
Application.EnableEvents = False
For i = 21 To lignes
Cells(i, 1) = i - 20
Cells(i, 1).RowHeight = 15
With Cells(i, 5).Validation
Cells(i, 5).Validation.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=Communes"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "Sélection"
.ErrorTitle = ""
.InputMessage = "Sélectionnez une commune."
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
With Cells(i, 6).Validation
Cells(i, 6).Validation.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=Banques"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "Sélection"
.ErrorTitle = ""
.InputMessage = "Sélectionnez une banque."
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Cells(i, 1).NumberFormat = "0"
With Range(Cells(i, 2), Cells(i, 7))
.NumberFormat = "@"
End With
With Cells(i, 8) = Replace(Cells(i, 8), ",", ".")
Cells(i, 8).NumberFormat = "#,##0.00 €_)"
Application.DecimalSeparator = ","
End With
With Range(Cells(i, 1), Cells(i, 8))
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignCenter
With .Font
.Name = "Times New Roman"
.FontStyle = "Normal"
.Size = 10
End With
.Borders((xlInsideVertical)).LineStyle = xlDot
.BorderAround Weight:=xlThin
End With
For Each celluleACapitaliser In Range(Cells(i, 1), Cells(i, 8))
celluleACapitaliser.Value = UCase(celluleACapitaliser.Value)
Next
Next
Application.EnableEvents = True
End If
End SubMerci d'avance pour votre aide !
Arnaud
Bonjour,
Pour éviter les conflits avec ta configuration Windows ...as-tu testé l'utilisation de :
Application.International(xlDecimalSeparator) En espèrant que cla t'aide ...