• Initiateur de la discussion Initiateur de la discussion marion
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

M

marion

Guest
Bonsoir au forum.
un prolème avec le format d'un nombre.
J'ai un userform qui apparait lorsque je me possitionne sur les cellule de la colonne B, il me donne des information qui sont positionnées un peu plus loin.
mon soucis et que je n'arrive pas a avoir des nombres entiers, il me donne des chiffres avec toutes les décimales. voici le code de l'userform:
si une personne peu me donner un petit coup de main merci d'avance.
A+ Marion


Private Sub Worksheet_SelectionChange(ByVal Target As Range)


If Not Application.Intersect(Range("B5:B" & Range("B65536").End(xlUp).Row), Range(Target.Address)) Is Nothing Then
Load UserForm1
With UserForm1
Selection.NumberFormat = "0"

.ListBox1.AddItem
.ListBox1.List(0, 0) = Range("CA4")
.ListBox1.List(0, 1) = Range("CA" & Range(Target.Address).Row)

.ListBox1.AddItem
.ListBox1.List(1, 0) = Range("BZ4")
.ListBox1.List(1, 1) = Range("BZ" & Range(Target.Address).Row)

.ListBox1.AddItem
.ListBox1.List(2, 0) = Range("ga4")
.ListBox1.List(2, 1) = Range("ga" & Range(Target.Address).Row)

.ListBox1.AddItem
.ListBox1.List(3, 0) = Range("gb4")
.ListBox1.List(3, 1) = Range("gb" & Range(Target.Address).Row)

.ListBox1.AddItem
.ListBox1.List(4, 0) = Range("gC4")
.ListBox1.List(4, 1) = Range("gC" & Range(Target.Address).Row)

.ListBox1.AddItem
.ListBox1.List(5, 0) = Range("gD4")
.ListBox1.List(5, 1) = Range("gD" & Range(Target.Address).Row)

.ListBox1.AddItem
.ListBox1.List(6, 0) = Range("gE4")
.ListBox1.List(6, 1) = Range("gE" & Range(Target.Address).Row)

.ListBox1.AddItem
.ListBox1.List(7, 0) = Range("gF4")
.ListBox1.List(7, 1) = Range("gF" & Range(Target.Address).Row)
.Show
End With
End If
End Sub
 
Salut Marion, salut le forum,

Je pense qu'il y a mieux mais comme ça, ça marche :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("B5:B" & Range("B65536").End(xlUp).Row), Range(Target.Address)) Is Nothing Then
Load UserForm1
With UserForm1

.ListBox1.AddItem
.ListBox1.List(0, 0) = Format(Range("CA4"), "0")
.ListBox1.List(0, 1) = Format(Range("CA" & Range(Target.Address).Row), "0")

.ListBox1.AddItem
.ListBox1.List(1, 0) = Format(Range("BZ4"), "0")
.ListBox1.List(1, 1) = Format(Range("BZ" & Range(Target.Address).Row), "0")

.ListBox1.AddItem
.ListBox1.List(2, 0) = Format(Range("ga4"), "0")
.ListBox1.List(2, 1) = Format(Range("ga" & Range(Target.Address).Row), "0")

.ListBox1.AddItem
.ListBox1.List(3, 0) = Format(Range("gb4"), "0")
.ListBox1.List(3, 1) = Format(Range("gb" & Range(Target.Address).Row), "0")

.ListBox1.AddItem
.ListBox1.List(4, 0) = Format(Range("gC4"), "0")
.ListBox1.List(4, 1) = Format(Range("gC" & Range(Target.Address).Row), "0")

.ListBox1.AddItem
.ListBox1.List(5, 0) = Format(Range("gD4"), "0")
.ListBox1.List(5, 1) = Format(Range("gD" & Range(Target.Address).Row), "0")

.ListBox1.AddItem
.ListBox1.List(6, 0) = Format(Range("gE4"), "0")
.ListBox1.List(6, 1) = Format(Range("gE" & Range(Target.Address).Row), "0")

.ListBox1.AddItem
.ListBox1.List(7, 0) = Format(Range("gF4"), "0")
.ListBox1.List(7, 1) = Format(Range("gF" & Range(Target.Address).Row), "0")
.Show
End With
End If
End Sub


À plus,

Robert
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD
Assurez vous de marquer un message comme solution pour une meilleure transparence.

Discussions similaires

Réponses
10
Affichages
538
Réponses
10
Affichages
846
Réponses
4
Affichages
551
Réponses
17
Affichages
2 K
Réponses
3
Affichages
841
Retour