OVH Cloud OVH Cloud

Problème de VBA

5 réponses
Avatar
Cestmoi
Bonjour à tous,

Voilà j'ai un Userform avec un code qui, lorsque je click sur "Valider" ,me
met tous les champs dans la feuille de donnée.
Voici le code

Private Sub Valider_Click()

Dim lLi As Long
Dim shDB As Worksheet
Set shDB = ThisWorkbook.Sheets("LISTE INTERNES")
lLi = shDB.Range("A1").CurrentRegion.Rows.Count + 1
shDB.Cells(lLi, 1).Value = Me.NOMINTERNE.Text
shDB.Cells(lLi, 21).Value = Me.DATENAISS.Text
shDB.Cells(lLi, 22).Value = Me.LIEUNAISS.Text
shDB.Cells(lLi, 13).Value = Me.MouF.Text
shDB.Cells(lLi, 15).Value = Me.NAN.Text
shDB.Cells(lLi, 2).Value = Me.Ecrouele.Text
shDB.Cells(lLi, 3).Value = Me.EDS.Text
shDB.Cells(lLi, 19).Value = Me.President.Text
shDB.Cells(lLi, 30).Value = Me.Interneen.Text
shDB.Cells(lLi, 14).Value = Me.Moeurs.Text
shDB.Cells(lLi, 18).Value = Me.Incompatibilite.Text
shDB.Cells(lLi, 24).Value = Me.Adresse.Text
shDB.Cells(lLi, 25).Value = Me.Codepostal.Text
shDB.Cells(lLi, 26).Value = Me.Ville.Text
shDB.Cells(lLi, 27).Value = Me.CCTC.Text
shDB.Cells(lLi, 28).Value = Me.Naturefaits.Text
shDB.Cells(lLi, 29).Value = Me.Avocat.Text
Cells(lLi, 7).Formula = "=IF(D" & lLi & "="""","""",IF(N" & lLi & "=1,D" &
lLi & "+1825,D" & lLi & "+1095))"
Cells(lLi, 9).Formula = "=IF((TODAY()-H" & lLi & ")>180,""rap à
reclamer"",""Non"")"
Cells(lLi, 12).Formula = "=IF(OR(J" & lLi & "="""",K" & lLi & "=""r""),""A
FIXER"",IF((TODAY()-J" & lLi & ")>170,""A FIXER"",""PAS 6 MOIS""))"
Cells(lLi, 23).Formula = "=IF(C" & lLi & "=""T"",""Actuellement au CHP de
Tournai"", IF(C" & lLi & "=""P"",""Actuellement à l'EDS de PAIFVE"", IF(C" &
lLi & "=""N"",""Actuellement à l'EP de Namur"",IF(C" & lLi &
"=""M"",""Actuellement au CHP de MONS"",""""))))"
shDB.Rows("1:" & lLi).Sort key1:=shDB.Range("A1"), order1:=xlAscending,
header:=xlYes
Set shDB = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub
--
La j'ai une boite de dialogue qui dit:

Erreur de compilation Membre ou Méthode de données introuvables.
Il me souligne Private Sub Valider_Click() en jaune.
Avant je n'ai jamais eu de problème avec et maintenant oui.
Peux-t-on m'aider svp.


Le bonheur est pour tous mais il se mérite

5 réponses

Avatar
Jacques93
Bonjour Cestmoi,

Il peut y avoir eu modification accidentelle du code.
Une méthode pour isoler la ligne en cause : tu les mets en remarque une
à une jusqu'à ce que tu n'aie plus l'erreur. C'est un peut 'bourrin',
mais tu n'as pas trop de lignes ...

Bonjour à tous,

Voilà j'ai un Userform avec un code qui, lorsque je click sur "Valider" ,me
met tous les champs dans la feuille de donnée.
Voici le code

Private Sub Valider_Click()

Dim lLi As Long
Dim shDB As Worksheet
Set shDB = ThisWorkbook.Sheets("LISTE INTERNES")
lLi = shDB.Range("A1").CurrentRegion.Rows.Count + 1
shDB.Cells(lLi, 1).Value = Me.NOMINTERNE.Text
shDB.Cells(lLi, 21).Value = Me.DATENAISS.Text
shDB.Cells(lLi, 22).Value = Me.LIEUNAISS.Text
shDB.Cells(lLi, 13).Value = Me.MouF.Text
shDB.Cells(lLi, 15).Value = Me.NAN.Text
shDB.Cells(lLi, 2).Value = Me.Ecrouele.Text
shDB.Cells(lLi, 3).Value = Me.EDS.Text
shDB.Cells(lLi, 19).Value = Me.President.Text
shDB.Cells(lLi, 30).Value = Me.Interneen.Text
shDB.Cells(lLi, 14).Value = Me.Moeurs.Text
shDB.Cells(lLi, 18).Value = Me.Incompatibilite.Text
shDB.Cells(lLi, 24).Value = Me.Adresse.Text
shDB.Cells(lLi, 25).Value = Me.Codepostal.Text
shDB.Cells(lLi, 26).Value = Me.Ville.Text
shDB.Cells(lLi, 27).Value = Me.CCTC.Text
shDB.Cells(lLi, 28).Value = Me.Naturefaits.Text
shDB.Cells(lLi, 29).Value = Me.Avocat.Text
Cells(lLi, 7).Formula = "=IF(D" & lLi & "="""","""",IF(N" & lLi & "=1,D" &
lLi & "+1825,D" & lLi & "+1095))"
Cells(lLi, 9).Formula = "=IF((TODAY()-H" & lLi & ")>180,""rap à
reclamer"",""Non"")"
Cells(lLi, 12).Formula = "=IF(OR(J" & lLi & "="""",K" & lLi & "=""r""),""A
FIXER"",IF((TODAY()-J" & lLi & ")>170,""A FIXER"",""PAS 6 MOIS""))"
Cells(lLi, 23).Formula = "=IF(C" & lLi & "=""T"",""Actuellement au CHP de
Tournai"", IF(C" & lLi & "=""P"",""Actuellement à l'EDS de PAIFVE"", IF(C" &
lLi & "=""N"",""Actuellement à l'EP de Namur"",IF(C" & lLi &
"=""M"",""Actuellement au CHP de MONS"",""""))))"
shDB.Rows("1:" & lLi).Sort key1:=shDB.Range("A1"), order1:=xlAscending,
header:=xlYes
Set shDB = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub



--
Cordialement,

Jacques.

Avatar
isabelle
bonjour,

essaie en remplacant la déclaration
Dim lLi As Long
par
Dim lLi As Integer

isabelle

Bonjour à tous,

Voilà j'ai un Userform avec un code qui, lorsque je click sur "Valider" ,me
met tous les champs dans la feuille de donnée.
Voici le code

Private Sub Valider_Click()

Dim lLi As Long
Dim shDB As Worksheet
Set shDB = ThisWorkbook.Sheets("LISTE INTERNES")
lLi = shDB.Range("A1").CurrentRegion.Rows.Count + 1
shDB.Cells(lLi, 1).Value = Me.NOMINTERNE.Text
shDB.Cells(lLi, 21).Value = Me.DATENAISS.Text
shDB.Cells(lLi, 22).Value = Me.LIEUNAISS.Text
shDB.Cells(lLi, 13).Value = Me.MouF.Text
shDB.Cells(lLi, 15).Value = Me.NAN.Text
shDB.Cells(lLi, 2).Value = Me.Ecrouele.Text
shDB.Cells(lLi, 3).Value = Me.EDS.Text
shDB.Cells(lLi, 19).Value = Me.President.Text
shDB.Cells(lLi, 30).Value = Me.Interneen.Text
shDB.Cells(lLi, 14).Value = Me.Moeurs.Text
shDB.Cells(lLi, 18).Value = Me.Incompatibilite.Text
shDB.Cells(lLi, 24).Value = Me.Adresse.Text
shDB.Cells(lLi, 25).Value = Me.Codepostal.Text
shDB.Cells(lLi, 26).Value = Me.Ville.Text
shDB.Cells(lLi, 27).Value = Me.CCTC.Text
shDB.Cells(lLi, 28).Value = Me.Naturefaits.Text
shDB.Cells(lLi, 29).Value = Me.Avocat.Text
Cells(lLi, 7).Formula = "=IF(D" & lLi & "="""","""",IF(N" & lLi & "=1,D" &
lLi & "+1825,D" & lLi & "+1095))"
Cells(lLi, 9).Formula = "=IF((TODAY()-H" & lLi & ")>180,""rap à
reclamer"",""Non"")"
Cells(lLi, 12).Formula = "=IF(OR(J" & lLi & "="""",K" & lLi & "=""r""),""A
FIXER"",IF((TODAY()-J" & lLi & ")>170,""A FIXER"",""PAS 6 MOIS""))"
Cells(lLi, 23).Formula = "=IF(C" & lLi & "=""T"",""Actuellement au CHP de
Tournai"", IF(C" & lLi & "=""P"",""Actuellement à l'EDS de PAIFVE"", IF(C" &
lLi & "=""N"",""Actuellement à l'EP de Namur"",IF(C" & lLi &
"=""M"",""Actuellement au CHP de MONS"",""""))))"
shDB.Rows("1:" & lLi).Sort key1:=shDB.Range("A1"), order1:=xlAscending,
header:=xlYes
Set shDB = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub


Avatar
Jacques93
Bonjour isabelle,

Si le problème venait de là, il y aurait un autre problème.
Une variable de type Integer peut contenir des valeurs entre -32768 et
32767, une feuille a 65536 ligne, il faut donc bien une variable de type
Long pour atteindre toutes les lignes.

bonjour,

essaie en remplacant la déclaration
Dim lLi As Long
par
Dim lLi As Integer

isabelle


Bonjour à tous,

Voilà j'ai un Userform avec un code qui, lorsque je click sur
"Valider" ,me met tous les champs dans la feuille de donnée.
Voici le code
Private Sub Valider_Click()

Dim lLi As Long
Dim shDB As Worksheet
Set shDB = ThisWorkbook.Sheets("LISTE INTERNES")
lLi = shDB.Range("A1").CurrentRegion.Rows.Count + 1
shDB.Cells(lLi, 1).Value = Me.NOMINTERNE.Text
shDB.Cells(lLi, 21).Value = Me.DATENAISS.Text
shDB.Cells(lLi, 22).Value = Me.LIEUNAISS.Text
shDB.Cells(lLi, 13).Value = Me.MouF.Text
shDB.Cells(lLi, 15).Value = Me.NAN.Text
shDB.Cells(lLi, 2).Value = Me.Ecrouele.Text
shDB.Cells(lLi, 3).Value = Me.EDS.Text
shDB.Cells(lLi, 19).Value = Me.President.Text
shDB.Cells(lLi, 30).Value = Me.Interneen.Text
shDB.Cells(lLi, 14).Value = Me.Moeurs.Text
shDB.Cells(lLi, 18).Value = Me.Incompatibilite.Text
shDB.Cells(lLi, 24).Value = Me.Adresse.Text
shDB.Cells(lLi, 25).Value = Me.Codepostal.Text
shDB.Cells(lLi, 26).Value = Me.Ville.Text
shDB.Cells(lLi, 27).Value = Me.CCTC.Text
shDB.Cells(lLi, 28).Value = Me.Naturefaits.Text
shDB.Cells(lLi, 29).Value = Me.Avocat.Text
Cells(lLi, 7).Formula = "=IF(D" & lLi & "="""","""",IF(N" & lLi &
"=1,D" & lLi & "+1825,D" & lLi & "+1095))"
Cells(lLi, 9).Formula = "=IF((TODAY()-H" & lLi & ")>180,""rap à
reclamer"",""Non"")"
Cells(lLi, 12).Formula = "=IF(OR(J" & lLi & "="""",K" & lLi &
"=""r""),""A FIXER"",IF((TODAY()-J" & lLi & ")>170,""A FIXER"",""PAS 6
MOIS""))"
Cells(lLi, 23).Formula = "=IF(C" & lLi & "=""T"",""Actuellement au CHP
de Tournai"", IF(C" & lLi & "=""P"",""Actuellement à l'EDS de
PAIFVE"", IF(C" & lLi & "=""N"",""Actuellement à l'EP de Namur"",IF(C"
& lLi & "=""M"",""Actuellement au CHP de MONS"",""""))))"
shDB.Rows("1:" & lLi).Sort key1:=shDB.Range("A1"),
order1:=xlAscending, header:=xlYes
Set shDB = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub




--
Cordialement,

Jacques.


Avatar
Cestmoi
Merci
j'ai fais la méthode de Jacques et c'est à la ligne"Moeurs" que ça a
remarché. J'ai modifier Moeurs en MOEURS et cela a marché. Merci encore.
Euh "bourrin" veut dire quoi exactement ? moi je pense à un mauvais
fonctionnement incompréhensible ?
Merci encore


Bonjour à tous,

Voilà j'ai un Userform avec un code qui, lorsque je click sur "Valider" ,me
met tous les champs dans la feuille de donnée.
Voici le code

Private Sub Valider_Click()

Dim lLi As Long
Dim shDB As Worksheet
Set shDB = ThisWorkbook.Sheets("LISTE INTERNES")
lLi = shDB.Range("A1").CurrentRegion.Rows.Count + 1
shDB.Cells(lLi, 1).Value = Me.NOMINTERNE.Text
shDB.Cells(lLi, 21).Value = Me.DATENAISS.Text
shDB.Cells(lLi, 22).Value = Me.LIEUNAISS.Text
shDB.Cells(lLi, 13).Value = Me.MouF.Text
shDB.Cells(lLi, 15).Value = Me.NAN.Text
shDB.Cells(lLi, 2).Value = Me.Ecrouele.Text
shDB.Cells(lLi, 3).Value = Me.EDS.Text
shDB.Cells(lLi, 19).Value = Me.President.Text
shDB.Cells(lLi, 30).Value = Me.Interneen.Text
shDB.Cells(lLi, 14).Value = Me.Moeurs.Text
shDB.Cells(lLi, 18).Value = Me.Incompatibilite.Text
shDB.Cells(lLi, 24).Value = Me.Adresse.Text
shDB.Cells(lLi, 25).Value = Me.Codepostal.Text
shDB.Cells(lLi, 26).Value = Me.Ville.Text
shDB.Cells(lLi, 27).Value = Me.CCTC.Text
shDB.Cells(lLi, 28).Value = Me.Naturefaits.Text
shDB.Cells(lLi, 29).Value = Me.Avocat.Text
Cells(lLi, 7).Formula = "=IF(D" & lLi & "="""","""",IF(N" & lLi & "=1,D" &
lLi & "+1825,D" & lLi & "+1095))"
Cells(lLi, 9).Formula = "=IF((TODAY()-H" & lLi & ")>180,""rap à
reclamer"",""Non"")"
Cells(lLi, 12).Formula = "=IF(OR(J" & lLi & "="""",K" & lLi & "=""r""),""A
FIXER"",IF((TODAY()-J" & lLi & ")>170,""A FIXER"",""PAS 6 MOIS""))"
Cells(lLi, 23).Formula = "=IF(C" & lLi & "=""T"",""Actuellement au CHP de
Tournai"", IF(C" & lLi & "=""P"",""Actuellement à l'EDS de PAIFVE"", IF(C" &
lLi & "=""N"",""Actuellement à l'EP de Namur"",IF(C" & lLi &
"=""M"",""Actuellement au CHP de MONS"",""""))))"
shDB.Rows("1:" & lLi).Sort key1:=shDB.Range("A1"), order1:=xlAscending,
header:=xlYes
Set shDB = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub
--
La j'ai une boite de dialogue qui dit:

Erreur de compilation Membre ou Méthode de données introuvables.
Il me souligne Private Sub Valider_Click() en jaune.
Avant je n'ai jamais eu de problème avec et maintenant oui.
Peux-t-on m'aider svp.


Le bonheur est pour tous mais il se mérite


Avatar
Cestmoi
Re bonjour

je croyais mais un autre problème:

si je peux travailler avec l'UF il affiche une boite de dialogue quand j'ai
'valider' et que je retourne dans la feuille de donnée:
Erreur d'éxécution '91' Variable objet ou variable de bloc With non définie.
Or c'est dans un module

J'ai Sub AJOUTER()
AJOUT.Show
End Sub

Alors que les 2 autres macros affichant les autres UF ne me disent rien du
tout.
Merci d'avance.


Merci
j'ai fais la méthode de Jacques et c'est à la ligne"Moeurs" que ça a
remarché. J'ai modifier Moeurs en MOEURS et cela a marché. Merci encore.
Euh "bourrin" veut dire quoi exactement ? moi je pense à un mauvais
fonctionnement incompréhensible ?
Merci encore


Bonjour à tous,

Voilà j'ai un Userform avec un code qui, lorsque je click sur "Valider" ,me
met tous les champs dans la feuille de donnée.
Voici le code

Private Sub Valider_Click()

Dim lLi As Long
Dim shDB As Worksheet
Set shDB = ThisWorkbook.Sheets("LISTE INTERNES")
lLi = shDB.Range("A1").CurrentRegion.Rows.Count + 1
shDB.Cells(lLi, 1).Value = Me.NOMINTERNE.Text
shDB.Cells(lLi, 21).Value = Me.DATENAISS.Text
shDB.Cells(lLi, 22).Value = Me.LIEUNAISS.Text
shDB.Cells(lLi, 13).Value = Me.MouF.Text
shDB.Cells(lLi, 15).Value = Me.NAN.Text
shDB.Cells(lLi, 2).Value = Me.Ecrouele.Text
shDB.Cells(lLi, 3).Value = Me.EDS.Text
shDB.Cells(lLi, 19).Value = Me.President.Text
shDB.Cells(lLi, 30).Value = Me.Interneen.Text
shDB.Cells(lLi, 14).Value = Me.Moeurs.Text
shDB.Cells(lLi, 18).Value = Me.Incompatibilite.Text
shDB.Cells(lLi, 24).Value = Me.Adresse.Text
shDB.Cells(lLi, 25).Value = Me.Codepostal.Text
shDB.Cells(lLi, 26).Value = Me.Ville.Text
shDB.Cells(lLi, 27).Value = Me.CCTC.Text
shDB.Cells(lLi, 28).Value = Me.Naturefaits.Text
shDB.Cells(lLi, 29).Value = Me.Avocat.Text
Cells(lLi, 7).Formula = "=IF(D" & lLi & "="""","""",IF(N" & lLi & "=1,D" &
lLi & "+1825,D" & lLi & "+1095))"
Cells(lLi, 9).Formula = "=IF((TODAY()-H" & lLi & ")>180,""rap à
reclamer"",""Non"")"
Cells(lLi, 12).Formula = "=IF(OR(J" & lLi & "="""",K" & lLi & "=""r""),""A
FIXER"",IF((TODAY()-J" & lLi & ")>170,""A FIXER"",""PAS 6 MOIS""))"
Cells(lLi, 23).Formula = "=IF(C" & lLi & "=""T"",""Actuellement au CHP de
Tournai"", IF(C" & lLi & "=""P"",""Actuellement à l'EDS de PAIFVE"", IF(C" &
lLi & "=""N"",""Actuellement à l'EP de Namur"",IF(C" & lLi &
"=""M"",""Actuellement au CHP de MONS"",""""))))"
shDB.Rows("1:" & lLi).Sort key1:=shDB.Range("A1"), order1:=xlAscending,
header:=xlYes
Set shDB = Nothing
Application.Calculation = xlCalculationAutomatic
End Sub
--
La j'ai une boite de dialogue qui dit:

Erreur de compilation Membre ou Méthode de données introuvables.
Il me souligne Private Sub Valider_Click() en jaune.
Avant je n'ai jamais eu de problème avec et maintenant oui.
Peux-t-on m'aider svp.


Le bonheur est pour tous mais il se mérite