Importerfeuille

Bonjour,

J'ai une erreur objet requis au niveau de

Workbooks(nomfichier).Worksheets(Sheet.Name).Copy _
after:=Workbooks("MPS AUTO.xlsm").Worksheets(total)
une idée de pourquoi ?

Merci d'avance

Sub ImporterFeuilleCal()
Dim repertoire As String, nomfichier As String, emplacement As String, feuilcal As Worksheet, total As Integer
Application.ScreenUpdating = False
Application.DisplayAlerts = False

emplacement = InputBox("SS-AA")
repertoire = "R:\Commun\LOGISTIQUE\30_ORDONNANCEMENT\ETUDE HI\OTOOL 1.6\" & "S" & emplacement & "\"
nomfichier = "ELIPS_Dijon_OFG__MPS_Extractio_070222.xls"
Workbooks.Open (repertoire & nomfichier)
For Each feuilcal In Workbooks(nomfichier).Worksheets
total = Workbooks("MPS AUTO.xlsm").Worksheets.Count
Workbooks(nomfichier).Worksheets(Sheet.Name).Copy _
after:=Workbooks("MPS AUTO.xlsm").Worksheets(total)
Next feuilcal
Workbooks(nomfichier).Close

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

Bonjour

Sheet.Name

n'est pas défini

un exemple de comment je dois le définir ?

Bonjour,

A tester :

Option Explicit

Sub ImporterFeuilleCal()

Dim Repertoire As String, Nomfichier As String, Emplacement As String
Dim WbSource As Workbook, WbCible As Workbook
Dim Feuilcal As Worksheet

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Set WbCible = Workbooks("MPS AUTO.xlsm")

    Emplacement = InputBox("SS-AA")
    Repertoire = "R:\Commun\LOGISTIQUE\30_ORDONNANCEMENT\ETUDE HI\OTOOL 1.6\" & "S" & Emplacement & "\"
    Nomfichier = "ELIPS_Dijon_OFG__MPS_Extractio_070222.xls"

    Set WbSource = Workbooks.Open(Repertoire & Nomfichier)

    For Each Feuilcal In WbSource.Sheets
       Feuilcal.Copy after:=WbCible.Sheets(WbCible.Sheets.Count)
    Next Feuilcal
    WbSource.Close savechanges:=False

    Set WbCible = Nothing:  Set WbSource = Nothing

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

End Sub

Merci Eric pour ta proposition

J'ai une erreur à ce niveau

Feuilcal.Copy after:=WbCible.Sheets(WbCible.Sheets.Count)

Met ton code en entier.

Au temps pour moi, il n'y a pas d'erreurs.

merci beaucoup !
Rechercher des sujets similaires à "importerfeuille"