Numéroter colone K fichier excel

avyrex1926 Messages postés 360 Date d'inscription dimanche 3 décembre 2006 Statut Membre Dernière intervention 3 janvier 2012 - 15 mai 2007 à 20:28
avyrex1926 Messages postés 360 Date d'inscription dimanche 3 décembre 2006 Statut Membre Dernière intervention 3 janvier 2012 - 15 mai 2007 à 22:08
Bonjour,

Je voudrais rajouter dans la colone K du fichier excel les chiffre de 1 à 20 pour numéroter les lignes qui sont assigné.

Comment faire svp?

<hr size="2" width="100%" />
Private Sub Form_Load()

    Dim WorkB As New Excel.Workbook
    Dim WorkS As Excel.Worksheet
    Dim i     As Long, PLV As Long

On Error Resume Next
Set obExcelApp = GetObject(, "Excel.Application")
Sheets("Feuil1").Select

Text1 = Range("A1") + 1
commande.Show
Range("A1") = Text1
ActiveWorkbook.Save
 Timer1.Interval = 100
     Label1.Caption = ""
    
     Application.ScreenUpdating = False
    
   'Assigner les lignes au PO
    
'Set obExcelApp = GetObject.Sheets("Feuil1")
PLV = obExcelApp.Range("B65536").End(xlUp).Row + 1

For i = PLV To PLV + 19
       
    obExcelApp.Cells(i, 1).Value = "PB"
    obExcelApp.Cells(i, 2).Value = "'" & Format(Range("A1").Value, "00000")
Next i

ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub
<hr size="2" width="100%" />

1 réponse

avyrex1926 Messages postés 360 Date d'inscription dimanche 3 décembre 2006 Statut Membre Dernière intervention 3 janvier 2012 3
15 mai 2007 à 22:08
J'y est été surement de la façon la plus longue mais bon, pour l'instant, ça fonctionne:

Private Sub Form_Load()

    Dim WorkB As New Excel.Workbook
    Dim WorkS As Excel.Worksheet
    Dim i     As Long, PLV As Long

On Error Resume Next
Set obExcelApp = GetObject(, "Excel.Application")
Sheets("Feuil1").Select

Text1 = Range("A1") + 1
commande.Show
Range("A1") = Text1
ActiveWorkbook.Save
 Timer1.Interval = 100
     Label1.Caption = ""
    
     Application.ScreenUpdating = False
    
   'Assigner les lignes au PO
    
'Set obExcelApp = GetObject.Sheets("Feuil1")
PLV = obExcelApp.Range("B65536").End(xlUp).Row + 1

For i = PLV To PLV + 19
       
    obExcelApp.Cells(i, 1).Value = "PB"
    obExcelApp.Cells(i, 2).Value = "'" & Format(Range("A1").Value, "00000")
    'obExcelApp.Cells(i, 9).Value = "1 to 20"
Next i

ActiveWorkbook.Save

Application.ScreenUpdating = True

Dim lIGNE As Long
   
    lIGNE = (Range("J1").End(xlDown).Row + 1)
Application.ScreenUpdating = False
    'ENTRER DES DONNÉES
   
    Range("J" & lIGNE) = Text2
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text8
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text14
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text20
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text26
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text32
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text38
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text44
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text50
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text56
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text62
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text68
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text74
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text80
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text86
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text92
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text98
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text104
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text110
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text116
    lIGNE = (Range("J1").End(xlDown).Row + 1)
    Range("J" & lIGNE) = Text122
   

End Sub
0
Rejoignez-nous