Probleme de sauvegardage
walidx123
Messages postés
4
Statut
Membre
-
michel_m Messages postés 18903 Date d'inscription Statut Contributeur Dernière intervention -
michel_m Messages postés 18903 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour à tous,
je suis débutant en VBA je veux enregistrer des données mais j'ai un erruer au sélection de la linge de l’enregistrement
voici le code et merci d'avance
Private Sub btn_enreg_Click()
If Len(Champ_nom) = 0 Or Len(champ_prenom) = 0 Or Len(champ_dte) = 0 Or Len(champ_email) = 0 Or Len(champ_tel) = 0 Or Len(champ_add) = 0 Then
MsgBox ("les Champs Sont Vide !!?")
Else
Windows("Application Entrée Sortie.xlsm").Activate
Sheets("Commercial").Select
'sélectionner la ligne 2 et insérer une nouvelle ligne
' errure est ici Rows("2:2").Select
Selection.Insert Shift:=xlDown
Selection.ClearFormats
'sélectionner les champs pour enregistrer les saisies
Range("A2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.Champ_nom
Range("B2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_prenom
Range("C2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_dte
Range("D2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_email
Range("E2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_tel
Range("F2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_add
' faire la bordure
Range("A2:F2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
ActiveWorkbook.Save
End If
End Sub
je suis débutant en VBA je veux enregistrer des données mais j'ai un erruer au sélection de la linge de l’enregistrement
voici le code et merci d'avance
Private Sub btn_enreg_Click()
If Len(Champ_nom) = 0 Or Len(champ_prenom) = 0 Or Len(champ_dte) = 0 Or Len(champ_email) = 0 Or Len(champ_tel) = 0 Or Len(champ_add) = 0 Then
MsgBox ("les Champs Sont Vide !!?")
Else
Windows("Application Entrée Sortie.xlsm").Activate
Sheets("Commercial").Select
'sélectionner la ligne 2 et insérer une nouvelle ligne
' errure est ici Rows("2:2").Select
Selection.Insert Shift:=xlDown
Selection.ClearFormats
'sélectionner les champs pour enregistrer les saisies
Range("A2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.Champ_nom
Range("B2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_prenom
Range("C2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_dte
Range("D2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_email
Range("E2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_tel
Range("F2").Select
ActiveCell.FormulaR1C1 = Sheet_nouveauCommercial.champ_add
' faire la bordure
Range("A2:F2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
ActiveWorkbook.Save
End If
End Sub