XL 2016 Ajouter des donnees dans differentes colonnes et mm ligne

FaruSZ

XLDnaute Occasionnel
Bonjour,

J’ai un tableau comme suit :

&.JPG






J’essaye de rajouter des tests a partir de la colonne N:N, on choisi le test a partir d’une combobox et ca se rajoute dans la colonne N. ( la combobox est dans un Userform qui s'affiche en cliquant sur le bouton ajouter DE)
Si je veux ajouter un test 100 par exemple, et ce numéro de test est déjà utilisé, le nouveau test se rajoute dans la colonne M :M de la même ligne que N° test 100 .
J'ai commencé a rédigé ce code mais ca ne marche pas:
'-------------Ajout tech essais--------------
Dim sh As Worksheet, rngTNo As Range, rngCol As Range, iRow As Long, i As Long
Dim ComboBox_No As MSForms.ComboBox, ComboBox_Test As MSForms.ComboBox

Set ComboBox_No = UserForm_SDE.ComboBox_No: Set ComboBox_Test = UserForm_SDE.ComboBox_Test
Set sh = ActiveWorkbook.Worksheets("suivi")
Set rngTNo = sh.Range("H7:H" & sh.Range("H" & Rows.Count).End(xlUp).Row) 'Test numbers range
If rngTNo.Cells.Count < 1 Then MsgBox _
"There necessary Test numbers range is missing...": Exit Sub
If rngTNo.NumberFormat <> "@" Then MsgBox _
"The Test numbers range must be formatted as text!": Exit Sub
iRow = rngTNo.Find(ComboBox_No.Value).Row 'row to be used for dropping the test
For i = 14 To 25
Set rngCol = sh.Range(sh.Cells(7, i), sh.Cells(sh.Cells(Rows.Count, i).End(xlUp).Row, i))
If rngCol.Find(ComboBox_Test.Value) Is Nothing Then
If sh.Cells(iRow, i).Value = "" Then
sh.Cells(iRow, i).Value = ComboBox_Test.Value: Exit For
End If
End If
Next
 

Pièces jointes

  • suivii.xlsm
    199.8 KB · Affichages: 8

Discussions similaires

Réponses
6
Affichages
202
Réponses
14
Affichages
621