Erreur vba

Nimbus

XLDnaute Occasionnel
Bonjour à tous,
Lorsque je lance mon programme vba, une erreur s'affiche ("La méthode n'appartient pas à la sélection") sur la ligne en gras et je ne trouve pas comment résoudre ce problème...
Voici mon programme:

Code:
Private Sub Nouvelle_Saisie_Click()

  Dim Cel As Range, xchoixnosem, semExist As Range
  Dim i As Long, xdlgn As Long, xdlgn1 As Long
  Dim wb As Workbook
  
  Application.ScreenUpdating = False
  
  ' Contrôle de la saisie
  xchoixnosem = InputBox(Prompt:="Indiquez le numéro de semaine (chiffre compris entre 1 et 52), puis Valider par la touche Entrée du clavier ?", Title:="Choix de la semaine")
      ' Si bouton Annuler
      If xchoixnosem = "" Then Exit Sub
      If xchoixnosem < 1 Or xchoixnosem > 52 Then
          MsgBox "Le numéro de la semaine doit être un chiffre compris entre 1 et 52.", vbCritical, "Choix de la semaine"
          Application.ScreenUpdating = True
          Exit Sub
      End If

  ' Extraction des données
  
    Dim MaSelection As Range
    Dim wb_destination As Workbook
    Dim ws_destination As Worksheet
 
    Set wb_destination = Workbooks("MC_essai2.xlsm")
    Set ws_destination = wb_destination.Worksheets("Saisie")
 
    Dim Wb_source As Workbook
    Dim Ws_source As Worksheet
    Dim ZoneColle As Range
   
    ' Récupération des données dans classeur fermé que j'ouvre !!
 
    Workbooks("MC_essai2.xlsm").Worksheets("Saisie").Cells.ClearContents
 
' Premier atelier

    Set Wb_source = Workbooks.Open(Filename:="\\Gpao\commun\30_QUALITE\\307_Gestion_de_service\Lyse\Main_courante_atelier\MC_Plastique.xlsm")
    Set Ws_source = Wb_source.Worksheets("Synthese")
[COLOR="#FF0000"]   Set MaSelection = Ws_source.Range(Range("A5"), Cells(Range("B65536").End(xlUp).Row, 19))  [/COLOR]    MaSelection.SpecialCells(xlCellTypeVisible).Copy _
            ws_destination.Range("A5")
    Wb_source.Close False
 
' zonecolle fait référence à Workbooks("MC_essai.xlsm").Worksheets("Saisie")

    Set ZoneColle = ws_destination.Range("a65536").End(xlUp).Offset(1, 0)
    Set Wb_source = Workbooks.Open(Filename:="\\Gpao\commun\30_QUALITE\\307_Gestion_de_service\Lyse\Main_courante_atelier\MC_Expédition.xlsm")
    Set Ws_source = Wb_source.Worksheets("Synthese")
    Set MaSelection = Ws_source.Range(Range("A5"), Cells(Range("B65536").End(xlUp).Row, 19))
    MaSelection.SpecialCells(xlCellTypeVisible).Copy _
            ZoneColle
    Wb_source.Close False
 
'Prochain atelier

    Set ZoneColle = ws_destination.Range("a65536").End(xlUp).Offset(1, 0)
    Set Wb_source = Workbooks.Open(Filename:="\\Gpao\commun\30_QUALITE\\307_Gestion_de_service\Lyse\Main_courante_atelier\MC_Finition.xlsm")
    Set Ws_source = Wb_source.Worksheets("Synthese")
    Set MaSelection = Ws_source.Range(Range("A5"), Cells(Range("B65536").End(xlUp).Row, 19))
    ' MaSelection.Select
    MaSelection.SpecialCells(xlCellTypeVisible).Copy _
            ZoneColle
    Wb_source.Close False
 
End Sub

Merci de m'aider sur ce point!

Nimbus
 

Dranreb

XLDnaute Barbatruc
Re : Erreur vba

Bonjour.

Probablement :
VB:
Set MaSelection = Ws_source.Range(Ws_source.Range("A5"), Ws_source.Cells(Ws_source.Range("B65536").End(xlUp).Row, 19))
Que j'écrirais probablement:
VB:
Set MaSelection = Ws_source.[A5].Resize(Ws_source.[B65536].End(xlUp).Row - 4, 19))
 

Discussions similaires

Statistiques des forums

Discussions
312 216
Messages
2 086 351
Membres
103 195
dernier inscrit
martel.jg