Erreur copier coller

Résolu/Fermé
juer31 Messages postés 107 Date d'inscription mercredi 16 décembre 2015 Statut Membre Dernière intervention 25 mars 2024 - 17 avril 2019 à 21:06
Frenchie83 Messages postés 2240 Date d'inscription lundi 6 mai 2013 Statut Membre Dernière intervention 11 août 2023 - 19 avril 2019 à 15:56
Bonjour,

J'ai un code pour copier des valeur de cellules précise vers une autre feuille mais je bloque directemant a la ligne suivante qui est en gras. je n'arrive pas a comprendre ce qui peut clocher.

Quelqu'un peut m'aider?

Option Explicit


Public Const FC = "CALCULS"
Public Const PClient = "C5"
Public Const PContact = "F5"
Public Const DesProjet = "C8"
Public Const NoProjet = "F8"
Public Const TypePrix = "C11"
Public Const Coutant = "E24"
Public Const Vendant = "H24"
Public Const NoteProjet = "I5"


Public Const FH = "HISTORIQUES"
Public Const HPClient = "C"
Public Const HPContact = "E"
Public Const HDesProjet = "G"
Public Const HNoProjet = "I"
Public Const HTypePrix = "J"
Public Const HCoutant = "K"
Public Const HVendant = "L"
Public Const HNoteProjet = "M"
Public Const lideb = 5

Public Sub Histo()
Dim PClient As String, PContact As String, DesProjet As String, NoProjet As String, TypePrix As String, Coutant As String, Vendant As String, NoteProjet As String, liFH As Long
With Sheets(FC)
PClient = .Range(HPClient).Cells(1, 1).Value
PContact = .Range(HPContact).Cells(1, 1).Value
DesProjet = .Range(HDesProjet).Cells(1, 1).Value
NoProjet = .Range(HNoProjet).Cells(1, 1).Value
TypePrix = .Range(HTypePrix).Cells(1, 1).Value
Coutant = .Range(HCoutant).Cells(1, 1).Value
Vendant = .Range(HVendant).Cells(1, 1).Value
NoteProjet = .Range(HNoteProjet).Cells(1, 1).Value

End With
With Sheets(FH)
liFH = .Range(HPClient & Rows.Count).End(xlUp).Row + 1
If liFH <= lideb Then liFH = lideb + 1
.Range(HPClient & liFH).Value = PClient
.Range(HPContact & liFH).Value = PContact
.Range(HDesProjet & liFH).Value = DesProjet
.Range(HNoProjet & liFH).Value = NoProjet
.Range(HTypePrix & liFH).Value = TypePrix
.Range(HCoutant & liFH).Value = Coutant
.Range(HVendant & liFH).Value = Vendant
.Range(HNoteProjet & liFH).Value = NoteProjet

End With
End Sub
A voir également:

2 réponses

Frenchie83 Messages postés 2240 Date d'inscription lundi 6 mai 2013 Statut Membre Dernière intervention 11 août 2023 337
18 avril 2019 à 04:38
Bonjour,

Lancez votre macro, sur la ligne en défaut, faite un débogage, quelle est la valeur de "HPClient"?
Etes-vous sûr qu'il s'agit d'une plage?
Range(HPClient) vous semble t-il correct?

Cdlt
0
juer31 Messages postés 107 Date d'inscription mercredi 16 décembre 2015 Statut Membre Dernière intervention 25 mars 2024 6
18 avril 2019 à 14:08
Je te joint un partie du fichier je ne vois pas ce qui marche pas
https://www.cjoint.com/c/IDsmhvtXHaW
0
Frenchie83 Messages postés 2240 Date d'inscription lundi 6 mai 2013 Statut Membre Dernière intervention 11 août 2023 337
19 avril 2019 à 15:56
Bonjour,

Code allégé
Public Sub Histo()
    Dim f1, f2
    Dim liFH As Long
    Set f1 = Sheets("CALCULS")
    Set f2 = Sheets("HISTORIQUES")
    liFH = f2.[C10000].End(xlUp).Row + 1
    f2.Range("C" & liFH).Value = f1.[C5]
    f2.Range("E" & liFH).Value = f1.[F5]
    f2.Range("G" & liFH).Value = f1.[C8]
    f2.Range("I" & liFH).Value = f1.[F8]
    f2.Range("J" & liFH).Value = f1.[C11]
    f2.Range("K" & liFH).Value = f1.[E24]
    f2.Range("L" & liFH).Value = f1.[H24]
    f2.Range("M" & liFH).Value = f1.[I5]
    ' etc ...
    Set f1 = Nothing
    Set f2 = Nothing
End Sub


Cdlt
0