Erreur copier coller
Résolu
juer31
Messages postés
120
Statut
Membre
-
Frenchie83 Messages postés 2254 Statut Membre -
Frenchie83 Messages postés 2254 Statut Membre -
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
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
2 réponses
-
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 -
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