Bonjour,
Je suis en train d'essayer de mettre en place un user form permettant de copier les mêmes éléments dans plusieurs fichiers à la fois.
Ca marche pour le fichier 1, çà ne marche plus pour le fichier 2 : pas de bug, mais j'ai l'impression que la cellule est transposée 1 fois, dans le fichier 1, et donc qu'il n'y a rien à copier dans le fichier 2.
=> ma question: que modifier dans le code pour que ce ne soit pas une sorte de "couper coller" mais de "copier coller" ? Sachant qu'après il faudra encore que je recopie ces données dans un 3ème fichier?
Voici le code:
Private Sub Validation_Click()
Dim Position As Integer
'Détermine l'index de la première ligne vide
Position = Worksheets("Fichier concaténé").Range("A999").End(xlUp).Row + 1
' Intègre les valeurs entrées dans le User Form sur la première ligne vide
Worksheets("Fichier concaténé").Range("A" & Position).Value = MasterData.SupplierName.Value
If MasterData.SupplierName.Value = "" Then
MsgBox ("Please enter a supplier name")
Else
Worksheets("Fichier concaténé").Range("B" & Position).Value = MasterData.ContractNumber.Value
Worksheets("Fichier concaténé").Range("C" & Position).Value = MasterData.InternalClient.Value
Worksheets("Fichier concaténé").Range("D" & Position).Value = MasterData.InternalClientBU.Value
Worksheets("Fichier concaténé").Range("F" & Position).Value = MasterData.ContractAdministrator.Value
Worksheets("Fichier concaténé").Range("G" & Position).Value = MasterData.ContractAdministratorBU.Value
Worksheets("Fichier concaténé").Range("I" & Position).Value = MasterData.AP.Value
Unload Me
End If
'c'est là que çà ne marche plus, il copie du vide
Dim wb As Workbook
Set wb = GetObject("C:\Documents and Settings\...\blabla.xls")
wb.Activate
Dim Position2 As Integer
'Détermine l'index de la première ligne vide
Position2 = wb.Worksheets("Circuits").Range("A65000").End(xlUp).Row + 1
If MasterData.SupplierName.Value = "" Then
MsgBox ("Please enter a supplier name")
' Intègre les valeurs entrées dans le User Form sur la première ligne vide
wb.Worksheets("Circuits").Range("A" & Position2).Value = MasterData.SupplierName.Value
wb.Worksheets("Circuits").Range("C" & Position2).Value = MasterData.ContractNumber.Value
wb.Worksheets("Circuits").Range("H" & Position2).Value = MasterData.InternalClient.Value
wb.Worksheets("Circuits").Range("I" & Position2).Value = MasterData.InternalClientBU.Value
wb.Worksheets("Circuits").Range("F" & Position2).Value = MasterData.ContractAdministrator.Value
wb.Worksheets("Circuits").Range("G" & Position2).Value = MasterData.ContractAdministratorBU.Value
wb.Worksheets("Circuits").Range("J" & Position2).Value = MasterData.AP.Value
Unload Me
End If
End Sub
Merci d'avance de votre aide!!!
Je suis en train d'essayer de mettre en place un user form permettant de copier les mêmes éléments dans plusieurs fichiers à la fois.
Ca marche pour le fichier 1, çà ne marche plus pour le fichier 2 : pas de bug, mais j'ai l'impression que la cellule est transposée 1 fois, dans le fichier 1, et donc qu'il n'y a rien à copier dans le fichier 2.
=> ma question: que modifier dans le code pour que ce ne soit pas une sorte de "couper coller" mais de "copier coller" ? Sachant qu'après il faudra encore que je recopie ces données dans un 3ème fichier?
Voici le code:
Private Sub Validation_Click()
Dim Position As Integer
'Détermine l'index de la première ligne vide
Position = Worksheets("Fichier concaténé").Range("A999").End(xlUp).Row + 1
' Intègre les valeurs entrées dans le User Form sur la première ligne vide
Worksheets("Fichier concaténé").Range("A" & Position).Value = MasterData.SupplierName.Value
If MasterData.SupplierName.Value = "" Then
MsgBox ("Please enter a supplier name")
Else
Worksheets("Fichier concaténé").Range("B" & Position).Value = MasterData.ContractNumber.Value
Worksheets("Fichier concaténé").Range("C" & Position).Value = MasterData.InternalClient.Value
Worksheets("Fichier concaténé").Range("D" & Position).Value = MasterData.InternalClientBU.Value
Worksheets("Fichier concaténé").Range("F" & Position).Value = MasterData.ContractAdministrator.Value
Worksheets("Fichier concaténé").Range("G" & Position).Value = MasterData.ContractAdministratorBU.Value
Worksheets("Fichier concaténé").Range("I" & Position).Value = MasterData.AP.Value
Unload Me
End If
'c'est là que çà ne marche plus, il copie du vide
Dim wb As Workbook
Set wb = GetObject("C:\Documents and Settings\...\blabla.xls")
wb.Activate
Dim Position2 As Integer
'Détermine l'index de la première ligne vide
Position2 = wb.Worksheets("Circuits").Range("A65000").End(xlUp).Row + 1
If MasterData.SupplierName.Value = "" Then
MsgBox ("Please enter a supplier name")
' Intègre les valeurs entrées dans le User Form sur la première ligne vide
wb.Worksheets("Circuits").Range("A" & Position2).Value = MasterData.SupplierName.Value
wb.Worksheets("Circuits").Range("C" & Position2).Value = MasterData.ContractNumber.Value
wb.Worksheets("Circuits").Range("H" & Position2).Value = MasterData.InternalClient.Value
wb.Worksheets("Circuits").Range("I" & Position2).Value = MasterData.InternalClientBU.Value
wb.Worksheets("Circuits").Range("F" & Position2).Value = MasterData.ContractAdministrator.Value
wb.Worksheets("Circuits").Range("G" & Position2).Value = MasterData.ContractAdministratorBU.Value
wb.Worksheets("Circuits").Range("J" & Position2).Value = MasterData.AP.Value
Unload Me
End If
End Sub
Merci d'avance de votre aide!!!