Re : Coller données dans un autre classeur excel via spreadsheet
Je bloque vraiment.
En fait je sais pas comment référencer un classeur excel créé via userform et dont le nom correspond a un texte entré dans un textbox. J'arrive très bien a renvoyer des valeur saisies dans un spreadsheet vers une autre feuille d'un même classeur mais pas vers un autre classeur différent.
voici le code:
Private Sub CommandButton1_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim nom, test As String
Set xlApp = CreateObject("Excel.Application")
xlApp.SheetsInNewWorkbook = 1
Set xlBook = xlApp.Workbooks.Add
nom = ComboBox1.Value
test = ComboBox2.Value
xlBook.SaveAs (nom + test)
xlApp.Visible = True
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Name = "données"
Set xlSheet = Nothing
xlApp.SheetsInNewWorkbook = 3
xlApp.Quit
UserForm1.Spreadsheet2.Range("A2
20000").Copy
If IsEmpty(Range("C3")) Then
Worksheets("Données").Range("C3").Value.Paste
Else
Worksheets("Données").Range("IV2").End(xlToLeft).Offset(0, 1).PasteSpecial
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub