Derniere ligne d'un tableau comportant une mise en form
Bonjour
Je souhaite copier une mise en forme d'une ligne, et la coller a la fin de mon tableau excel avec cellule vide, mais cette ligne va varier.
Je suis arrivé à faire le code ci dessous, cependant j'arrive pas à que sa se répète et qu'a chaque fois ça me créer une nouvelle ligne a l'endroit de la dernière ligne de mon tableau (vide ou non vide peu importe).
Private Sub CommandButton1_Click()
With Worksheets(Sheets.Count)
Range("A10:L10").Select
Selection.Copy
End With
With Worksheets(Sheets.Count)
Dim derlig As Integer
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Range("A" & derlig + 1).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End With
End Sub
Cordialement
@+
bonjour
utilises-tu les "tableaux" dans Excel ?
avec eux, les mises en formes (figées ou conditionnelles) et les formules se reportent dans toute nouvelle ligne
Je te joint mon fichier comme ca sera plus simple, car je comprend pas ta question
Cela concerne juste l'userform 6...
Lorsque l'on clique sur le bouton ajouter un ligne.
Merci si tu peut m'aider
Bonjour et bienvenue sur le forum
Essaie ce code :
Private Sub CommandButton1_Click()
Range("A10:L10").Copy
Dim derlig As Integer
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Range("A" & derlig + 1).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A" & derlig + 1) = " "
Application.CutCopyMode = False
End Sub
Bye !
Re,
Merci de ton aide ca fonctionne.
@ bientôt
Re,
Maintenant j'ai un autre soucis,
Comment faire pour que ma valeur de ma listbox ou textbox aille directement dans la nouvelle ligne créer....
J'ai fait ca
Private Sub CommandButton52_Click()
Dim Plage As Range
With Worksheets(Sheets.Count) 'capacity
Set Plage = .Range("C4:F4")
End With
Plage = ComboBox2.Value
End Sub
Mais ("C4:F4") doit être remplacer par la dernière ligne du tableau...
De plus j'ai plusieurs listbox dans mon userform est comment faire pour ne pouvoir que choisir un listbox. Bloquer les autres
ex :
Listbox 1
Listbox2
Listbox3
Listbox4...
Et ne pouvoir selectionner que le 1 ou 2 ou 3 ou 4...
pour que dans la cellule excel il n'y ait que la valeur de la listbox1 ou 2 ou 3 ou 4...
Merci.
Pour bien comprendre ton problème, il me faudrait ton fichier et que tu expliques, à partir de ce tu as ce que tu veux obtenir.
Bye !
Voila le tableau excel en question
Je t'est tous expliquer dessus
Merci bien
@+
J'ai trouvé une sorte de solution qui consiste a si on clique sur le bouton oui alors combobox enable mais je n'arrive pas a le faire marcher :
Pouvez vous m'aider
Code :
Private Sub ComboBox1_Change()
If OptionButton2.Value = True Then
ComboBox1.Enabled = True
ComboBox1.BackStyle = fmBackStyleOpaque
End If
Dim plage As Range
Set plage = Sheets("TABLEAU DONNEE").Range("E4:E12")
TextBox1 = plage(1 + ComboBox1.ListIndex, 1)
End Sub
Private Sub UserForm_Initialize()
Me.ComboBox1.List = Sheets("TABLEAU DONNEE").Range("D4:D12").Value
end sub
Private Sub OptionButton1_Click()
End Sub
Private Sub OptionButton2_Click()
End Sub
Merci
Je ne sais pas ou positionner le code ci dessous: (dans
ComboBox1_Change() ou dans UserForm_Initialize())
If OptionButton2.Value = True Then
ComboBox1.Enabled = True
ComboBox1.BackStyle = fmBackStyleOpaque
End If
Cordialement
Désolé, mais je n'y parviens pas.
Je pense qu'il faudrait passer par un module de classe, mais ça, je ne maitrise pas...
Crée un nouveau fil à ce sujet sur le forum et peut-être que quelqu'un d'autre pourra t'aider.
Bonne chance !
Bye !
Re,
Merci de ton aide...
J'ai trouver une option qui permet de rendre une combobox enable. c'est déja ca...
Cordialement
Greg
Merci
Par contre quelqu'un sait comment grisé une combobox avec un code vba si optionbutton1 = True
Par contre quelqu'un sait comment grisé une combobox avec un code vba si optionbutton1 = True
En revanche, ça, je sais :
If OptionButton1 = True Then
Me.ComboBox1.ListIndex = 0 'Pour afficher le premier item de la liste
Me.ComboBox1.Enabled = False 'Pour le griser et rendre inaccessible le controle
End If
Bye !
Bonjour
est ce que quelqu'un c'est faire :
Si combobox 1 activer et le rest des combobox desactiver alors ecrire dans la cellule
Si combobox 2 activer et le rest des combobos desactiver alors ecrire dans la cellule
En faite c'est si au moins des combobox est active alors ecrire dans la cellule (c'est la meme cellule pour toute les combo...)
Voila le code que j'ai fait mais il marche pas...
Private Sub CommandButton1_Click()
With Worksheets(Sheets.Count)
Dim derlig As Integer
Dim plage As Range
If ComboBox1.Enabled = True Then
ElseIf ComboBox2.Enabled = False Then
ElseIf ComboBox3.Enabled = False Then
ElseIf ComboBox4.Enabled = False Then
ElseIf ComboBox5.Enabled = False Then
ElseIf ComboBox6.Enabled = False Then
ElseIf ComboBox7.Enabled = False Then
ElseIf ComboBox9.Enabled = False Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig + 1)
plage = ComboBox1.Value
End If
End With
With Worksheets(Sheets.Count)
Dim derlig1 As Integer
Dim plage1 As Range
If ComboBox2.Enabled = True Then
ElseIf ComboBox1.Enabled = False Then
ElseIf ComboBox3.Enabled = False Then
ElseIf ComboBox4.Enabled = False Then
ElseIf ComboBox5.Enabled = False Then
ElseIf ComboBox6.Enabled = False Then
ElseIf ComboBox7.Enabled = False Then
ElseIf ComboBox9.Enabled = False Then
derlig1 = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage1 = .Range("A" & derlig1 + 1)
plage1 = ComboBox2.Value
End If
End With
With Worksheets(Sheets.Count)
Dim derlig2 As Integer
Dim plage2 As Range
If ComboBox3.Enabled = True Then
ElseIf ComboBox1.Enabled = False Then
ElseIf ComboBox2.Enabled = False Then
ElseIf ComboBox4.Enabled = False Then
ElseIf ComboBox5.Enabled = False Then
ElseIf ComboBox6.Enabled = False Then
ElseIf ComboBox7.Enabled = False Then
ElseIf ComboBox9.Enabled = False Then
derlig2 = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage2 = .Range("A" & derlig2 + 1)
plage2 = ComboBox3.Value
End If
End With
With Worksheets(Sheets.Count)
Dim derlig3 As Integer
Dim plage3 As Range
If ComboBox4.Enabled = True Then
ElseIf ComboBox1.Enabled = False Then
ElseIf ComboBox2.Enabled = False Then
ElseIf ComboBox3.Enabled = False Then
ElseIf ComboBox5.Enabled = False Then
ElseIf ComboBox6.Enabled = False Then
ElseIf ComboBox7.Enabled = False Then
ElseIf ComboBox9.Enabled = False Then
derlig3 = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage3 = .Range("A" & derlig3 + 1)
plage3 = ComboBox4.Value
End If
End With
With Worksheets(Sheets.Count)
Dim derlig4 As Integer
Dim plage4 As Range
If ComboBox5.Enabled = True Then
ElseIf ComboBox1.Enabled = False Then
ElseIf ComboBox2.Enabled = False Then
ElseIf ComboBox3.Enabled = False Then
ElseIf ComboBox4.Enabled = False Then
ElseIf ComboBox6.Enabled = False Then
ElseIf ComboBox7.Enabled = False Then
ElseIf ComboBox9.Enabled = False Then
derlig4 = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage4 = .Range("A" & derlig4 + 1)
plage4 = ComboBox5.Value
End If
End With
With Worksheets(Sheets.Count)
Dim derlig5 As Integer
Dim plage5 As Range
If ComboBox6.Enabled = True Then
ElseIf ComboBox1.Enabled = False Then
ElseIf ComboBox2.Enabled = False Then
ElseIf ComboBox3.Enabled = False Then
ElseIf ComboBox4.Enabled = False Then
ElseIf ComboBox5.Enabled = False Then
ElseIf ComboBox7.Enabled = False Then
ElseIf ComboBox9.Enabled = False Then
derlig5 = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage5 = .Range("A" & derlig5 + 1)
plage5 = ComboBox6.Value
End If
End With
With Worksheets(Sheets.Count)
Dim derlig6 As Integer
Dim plage6 As Range
If ComboBox7.Enabled = True Then
ElseIf ComboBox1.Enabled = False Then
ElseIf ComboBox2.Enabled = False Then
ElseIf ComboBox3.Enabled = False Then
ElseIf ComboBox4.Enabled = False Then
ElseIf ComboBox5.Enabled = False Then
ElseIf ComboBox6.Enabled = False Then
ElseIf ComboBox9.Enabled = False Then
derlig6 = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage6 = .Range("A" & derlig6 + 1)
plage6 = ComboBox7.Value
End If
End With
With Worksheets(Sheets.Count)
Dim derlig7 As Integer
Dim plage7 As Range
If ComboBox9.Enabled = True Then
ElseIf ComboBox1.Enabled = False Then
ElseIf ComboBox2.Enabled = False Then
ElseIf ComboBox3.Enabled = False Then
ElseIf ComboBox4.Enabled = False Then
ElseIf ComboBox5.Enabled = False Then
ElseIf ComboBox6.Enabled = False Then
ElseIf ComboBox7.Enabled = False Then
derlig7 = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig7 + 1)
plage7 = ComboBox9.Value
End If
End With
blnCancel = True
Me.Hide
End Sub
Merci de votre aide
Cordialement
GREG
Re
J'ai fait ce code qui marche mais il doit y avoir plus simple
Private Sub CommandButton1_Click()
With Worksheets(Sheets.Count)
Dim derlig As Integer
Dim plage As Range
If OptionButton1.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig)
plage = ComboBox1.Value
End If
If OptionButton3.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig)
plage = ComboBox2.Value
End If
If OptionButton7.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig)
plage = ComboBox3.Value
End If
If OptionButton9.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig)
plage = ComboBox4.Value
End If
If OptionButton11.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig + 1)
plage = ComboBox5.Value
End If
If OptionButton13.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig)
plage = ComboBox6.Value
End If
If OptionButton15.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig)
plage = ComboBox7.Value
End If
If OptionButton17.Value = True Then
derlig = Cells.Find("*", , , , xlByRows, xlPrevious).Row
Set plage = .Range("A" & derlig)
plage = ComboBox9.Value
End If
End With
blnCancel = True
Me.Hide
End Sub
voila si vous pouvez m'aider