éviter sheets().select

Florian53

XLDnaute Impliqué
Bonjour le forum,

J'ai un code vba qui fonctionne bien par contre lors de son lancement elle active une des feuilles et je voudrais que tout ça soit transparent et ne pas voir de changement de feuille. je n'arrive pas à trouver un code qui fonctionne comme je le souhaite

Code:
With Sheets(Var_Famille100).Select
ligne = Range("B65536").End(xlUp).Offset(1, 0).Row
Cells(ligne, 2).Value = CDate(Date)
For i = 3 To 6
Cells(ligne, i).Value = Controls("TextBox" & 100 + i).Value
Next i
Cells(ligne, 7).Value = SousFamille100.Value
For i = 8 To 11
Cells(ligne, i).Value = Controls("TextBox" & 100 + i).Value
Next i
Famille100.Value = ""
SousFamille100.Value = ""
For i = 3 To 6
Controls("TextBox" & 100 + i).Value = ""
Next i
For i = 8 To 11
Controls("TextBox" & 100 + i).Value = ""
Next i
CheckBox100.Value = False
End With
 

phlaurent55

Nous a quittés en 2020
Repose en paix
Bonjour Florian,

le "Select" qui se trouve à la fin de la première ligne est inutile
mais il faudra modifier ton code car je ne voit aucune instruction précédée d'un point

à+
Philippe

Edit:
si le code présenté dans ta demande fonctionne comme tu le souhaites (mis à part le changement de feuille), tu as la solution suivante:

Mettre cette ligne devant ton code
Application.ScreenUpdating = False

et celle-ci en fin de code
Application.ScreenUpdating = True
 

Florian53

XLDnaute Impliqué
Voici le code en entier avec l'instruction :

Code:
Private Sub CommandButton111_Click()
Dim i As Byte, J As Byte
If TextBox109 = vbNullString Or TextBox104 = vbNullString Or Famille100 = vbNullString Or SousFamille100 = vbNullString Then
MsgBox ("Les champs marqués d'un astérisque (*) sont obligatoires.")
Famille100.SetFocus
Exit Sub
End If
Application.ScreenUpdating = False
With Sheets(Var_Famille100).Select
ligne = Range("B65536").End(xlUp).Offset(1, 0).Row
Cells(ligne, 2).Value = CDate(Date)
For i = 3 To 6
Cells(ligne, i).Value = Controls("TextBox" & 100 + i).Value
Next i
Cells(ligne, 7).Value = SousFamille100.Value
For i = 8 To 11
Cells(ligne, i).Value = Controls("TextBox" & 100 + i).Value
Next i
Famille100.Value = ""
SousFamille100.Value = ""
For i = 3 To 6
Controls("TextBox" & 100 + i).Value = ""
Next i
For i = 8 To 11
Controls("TextBox" & 100 + i).Value = ""
Next i
CheckBox100.Value = False
End With
Application.ScreenUpdating = True
Sheets("Tableau de bord").Activate

End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 192
Messages
2 086 054
Membres
103 110
dernier inscrit
Privé