NumberFormat

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
 
R

Robert

Guest
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
 

Discussions similaires

Réponses
4
Affichages
338
Réponses
17
Affichages
1 K

Statistiques des forums

Discussions
314 088
Messages
2 105 680
Membres
109 414
dernier inscrit
mennboug