Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 13/12/2011, 17h49   #1
Membre habitué
 
Homme christian
retraite
Inscription : avril 2010
Messages : 310
Détails du profil
Informations personnelles :
Nom : Homme christian
Âge : 56
Localisation : Espagne

Informations professionnelles :
Activité : retraite
Secteur : Industrie

Informations forums :
Inscription : avril 2010
Messages : 310
Points : 109
Points : 109
Par défaut probleme de code

Bonjour
je cherche a faire ceci:
choix a partir d'un combobox
chercher dans feuille "massage" toutes les lignes ou se trouve le mois affiche dans le combobox.
et faire la somme de la colonne R4:R65000
et mettre la valeur dans un textbox10.

Janvier 20
Janvier 35
soit dans le textbox 55
merci
cris
chris09300 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/12/2011, 18h20   #2
Expert Confirmé Sénior
 
Avatar de Qwazerty
 
Homme Stéphane
La très haute tension :D
Inscription : avril 2002
Messages : 2 446
Détails du profil
Informations personnelles :
Nom : Homme Stéphane
Âge : 32
Localisation : France

Informations professionnelles :
Activité : La très haute tension :D
Secteur : Service public

Informations forums :
Inscription : avril 2002
Messages : 2 446
Points : 4 620
Points : 4 620
Envoyer un message via MSN à Qwazerty
Salut
Massage au Barbecues ne change pas grand chose tu sais

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
 
Dim Total as double
With Me.ListView1
    .ListItems.Clear
    For Each V In ThisWorkBook.sheets("Massage").Range("A4:A" & Cells(Rows.Count, "A").End(xlUp).Row)
        'Ici on controle que le mois inscrit dans la tableau Excel correspond bien au mois choisi
        'Si aucun moi n'a été choisi, on inscrit toutes les données
        If (V.Value = ComboBox1.Text) Or (ComboBox1.Text = "") Then
            total = total + cdbl(v.offset(0,17).value)
        End If
    Next V
End With
TextBox.text = cstr(Total)
Un truc comme ça.

++
Qwaz
__________________

MagicQwaz := Harry Potter la baguette en moins
Le monde dans lequel on vit
HammerFest
Ma page perso DVP - Dernier Tutoriel : VBA & Internet Explorer
Qwazerty est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/12/2011, 18h24   #3
Expert Confirmé Sénior
 
Homme Daniel
aucune
Inscription : septembre 2011
Messages : 2 004
Détails du profil
Informations personnelles :
Nom : Homme Daniel
Localisation : France, Seine et Marne (Île de France)

Informations professionnelles :
Activité : aucune

Informations forums :
Inscription : septembre 2011
Messages : 2 004
Points : 4 037
Points : 4 037
Bonsoir,

Code :
Me.TextBox1 = Evaluate("SUMIF(MASSAGE!A4:A65000," & CInt(Me.ComboBox1.Value) & ",R4:R65000)")
__________________
Cordialement.

Daniel

Citation:
La plus perdue de toutes les journées est celle où l'on n'a pas ri.
Chamfort
Daniel.C est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/12/2011, 11h01   #4
Membre habitué
 
Homme christian
retraite
Inscription : avril 2010
Messages : 310
Détails du profil
Informations personnelles :
Nom : Homme christian
Âge : 56
Localisation : Espagne

Informations professionnelles :
Activité : retraite
Secteur : Industrie

Informations forums :
Inscription : avril 2010
Messages : 310
Points : 109
Points : 109
j'ai essayer de l'integre au code actuel sans y arrive
voici le code
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Private Sub ComboBox1_Change()
'On met a jour la liste
MaJList
End Sub
Private Sub userform_activate()
Application.ScreenUpdating = False
 Sheets("Massage").Select
 Application.DisplayFullScreen = True
 
'On selectionne la 1er entré de la combobox "Tous les mois"
ComboBox1.ListIndex = 0 'La liste est mise a jour (execution de ComboBox1_Change())
    Application.ScreenUpdating = True
End Sub
 
Sub MaJList()
    Application.ScreenUpdating = False
'il faut que tu supprimes ControleSource du TextBox1 dans les propriétés
Dim Total As Double
'Dans les propriété de ta ComboBox, met Style à fmStyleDropDownList, sa interdit à l'utilisateur de pouvoir taper n'importequoi
Dim ShMassage As Worksheet
'On pointe sur la feuille Barbecue
Set ShMassage = ThisWorkbook.Sheets("Massage")
 
With Resa_Massage
.StartUpPosition = 3
.Width = Application.Width
.Height = Application.Height
.Left = 0
.Top = 0
End With
 
'Suppression des titres de colonnes
ListView9.ColumnHeaders.Clear
 
'Alimentation des titres de colonne :
'Mais tu doit avoir la propriété View à lvwReport
ListView9.ColumnHeaders.Add , , "Mois", ListView9.Width * 0.08, lvwColumnLeft
ListView9.ColumnHeaders.Add , , "Nom", ListView9.Width * 0.15, lvwColumnLeft
ListView9.ColumnHeaders.Add , , "Nº MH", ListView9.Width * 0.06, lvwColumnCenter
ListView9.ColumnHeaders.Add , , "Date", ListView9.Width * 0.1, lvwColumnCenter
ListView9.ColumnHeaders.Add , , "Type de Massage", ListView9.Width * 0.25, lvwColumnLeft
ListView9.ColumnHeaders.Add , , "Réglement", ListView9.Width * 0.11, lvwColumnCenter
ListView9.ColumnHeaders.Add , , "Durée", ListView9.Width * 0.1, lvwColumnCenter
ListView9.ColumnHeaders.Add , , "Prix", ListView9.Width * 0.06, lvwColumnCenter
ListView9.ColumnHeaders.Add , , "Total", ListView9.Width * 0.09, lvwColumnCenter
 
With Me.ListView9
    .ListItems.Clear
    For Each V In ShMassage.Range("A4:A" & ShMassage.Cells(Rows.Count, "A").End(xlUp).Row)
        'Ici on controle que le mois inscrit dans la tableau Excel correspond bien au moi choisi
        'Si aucun moi n'a été choisi, on inscrit toutes les données
        'On passe les valeur en majuscule Ucase) pour ne pas etre dérangé par les majuscule en début de nom
        'Décembre n'est pas égale à décembre
        If (UCase(V.Text) = UCase(ComboBox1.Text)) Or (ComboBox1.Text = "Tous les mois") Then
            'On ajoute une ligne
            With .ListItems.Add(, , V.Text)
                .ForeColor = V.Font.Color
                For j = 1 To 8
                    .ListSubItems.Add , , V.Offset(0, j).Text
                    .ListSubItems(j).ForeColor = V.Offset(0, j).Font.Color
                Next j
            End With
            'On calcul le total
            Total = Total + CDbl(V.Offset(0, 8))
        End If
    Next V
End With
 
'On place Total dans le TExtbox1
TextBox1.Text = CStr(Total)
    Application.ScreenUpdating = True
End Sub
cordialement
cris

bonjour
je ne suis pas arrive a integre le code dans le mien, ainsi que celui du dernier post
Code :
Me.TextBox1 = Evaluate("SUMIF(MASSAGE!A4:A65000," & CInt(Me.ComboBox1.Value) & ",R4:R65000)")
merci
cris
chris09300 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/12/2011, 11h19   #5
Membre habitué
 
Homme christian
retraite
Inscription : avril 2010
Messages : 310
Détails du profil
Informations personnelles :
Nom : Homme christian
Âge : 56
Localisation : Espagne

Informations professionnelles :
Activité : retraite
Secteur : Industrie

Informations forums :
Inscription : avril 2010
Messages : 310
Points : 109
Points : 109
a force d'y regarder, j'ai fini par trouve.
ca fonctionne bien
merci beaucoup
cris
chris09300 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h30.


 
 
 
 
Partenaires

Hébergement Web