Macro VBA

  • Initiateur de la discussion Nana
  • Date de début
N

Nana

Guest
Bonjour, je voudrai créer un macro VBA qui me permette de générer dynamiquement le nombre de ligne de mon tableau.

Merci beaucoup
 
L

Lord Nelson

Guest
Salut,

Tu peux utiliser InputBox pour demander à l'utilisateur le nombre de lignes voulu, par exemple :

Sub MaMacro()
Dim NbL As Long
NbL = InputBox("Combien de lignes voulez-vous ?", "Lignes à créer", 1)

'...Suite de ton code pour créer NbL lignes.

End Sub

A+
LN
 
U

utilsfr

Guest
Bonjour

voici un code pour ajouter des lignes avec cadre

Sub ajoutlignes()
compteur = Application.InputBox(prompt:="Saisir une nombre de ligne à ajoute au tableau", Type:=1)
For i = 1 To compteur
Application.ScreenUpdating = False
Rows("8:8").Select 'Ligne de départ de l'ajout de ligne
Selection.Insert Shift:=xlDown
Range("B8:C8").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Next i
Range("c7").Select
End Sub



Cordialement
ROBERT René
 

Statistiques des forums

Discussions
312 502
Messages
2 089 047
Membres
104 011
dernier inscrit
dfr