Instruction de copie

bonjour

je n'arrive à regler mon petit soucis d'ecriture pour ce bout de code :

For Each xCell In ThisWorkbook.Sheets("Feuil1").Range("C21:C100")
    For Each WsB In WbkB.Worksheets
        If xCell = WsB.Name  And  WsB.Name = "comptabilité" Then

            WsB.Copy after:=WbkT.Sheets(WbkT.Sheets.Count)

le soucis est sur la ligne :

  If xCell = WsB.Name  And  WsB.Name = "comptabilité" Then

il n'y a aucune copie qui se fait , mais si j'enleve

 And  WsB.Name = "comptabilité"

ca marche , comment puis je faire

pour inclure cette instruction , mon ecriture semble pourtant correcte ?

merci

Bonjour

Avec un fichier c'est toujours plus facile

Suppositions:

Dans ta liste C21:C100, il n'y a pas le mot "comptabilité"

ou

Dans les pages du classeur WsB il n'y a pas de page "comptabilité"

ou

les deux

merci j'ai pu regler le probleme en ecrivant :

For Each xCell In ThisWorkbook.Sheets("Feuil1").Range("C21:C100")
    For Each WsB In WbkB.Worksheets
        If xCell = WsB.Name  Then

            WsB.Copy after:=WbkT.Sheets(WbkT.Sheets.Count)

                 end if
         next Wsb
  next xcell

For Each WsB In WbkB.Worksheets
        If WsB.Name  = "comptabilité" Then
WsB.Copy after:=WbkT.Sheets(WbkT.Sheets.Count)
  end if

      next Wsb

merci

Rechercher des sujets similaires à "instruction copie"