Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'sur quelle feuille est-on là ?
Dim l As Integer
Dim J As Integer
Dim I As Integer
Dim K As Integer
If Target.Address = "$G$8" Then
UserForm1.Show
End If
'Que fait ce formulaire ? A quoi sert-il ?
For l = 20 To 25
Cells(l, 4).Clear
Cells(l, 7).Clear
Next
' il n'est pas besoin d'aller sur une feuille (la sélectionner ou l'activer) pour récupérer sa valeur !
'Sheets("REFERENCE").Activate
'I = Range("A" & Rows.Count).End(xlUp).row [COLOR=#ff0000]'à quoi sert le calcul de ce I ?
I = sheets("reference").range....[/COLOR]
Sheets("MODELE_FACTURE").Activate
with sheets "reference"
For J = 1 To I
If Cells(16, 3).Value = .Cells(J, 1).Value Then
Cells(20 + K, 4).Value = .Cells(J, 2)
'************
Cells(20 + K, 6).Value ="=IF(ISNONTEXT(RC[-2]),"""",""jours, à un taux de journalier de "")"
Cells(20 + K, 7).Value = Sheets("REFERENCE").Cells(J, 3)
'************
Cells(20 + K, 8).Value = "=IF(ISNONTEXT(RC[-4]),"""",""pour un montant total de "")"
'***************
Cells(20 + K, 9).Value = "=IF(ISNONTEXT(RC[-5]),"""",PRODUCT(RC[-4],RC[-2]))"
K = K + 1
End If
Next J
end with
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Application.Intersect(Target, Range("E19:E25")) Is Nothing Then
' Sélection du classeur source à partir d'une fenêtre
cheminfichier = Application.GetOpenFilename("Fichiers Excels (*.xl*), *.xl*")
' Si on clique sur Annuler dans la fenêtre, on sort de la boucle
If cheminfichier = False Then
Exit Sub
End If
'Ouverture du classeur source
Workbooks.Open cheminfichier
nom = ActiveWorkbook.Name
'Sélection du nombre de jours passés par le consultant sur la mission
'ActiveCell.Select
Workbooks("Facturation.xlsm").Activate
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R16C3,'[" & nom & "]Timesheet'!R5C2:R47C3,2,FALSE)"
ActiveCell.Select
Cancel = True
[I]'Dans la deuxième, je n'ai toujours pas mis le code.. mais grossomodo, cela se résumerait à
'si cellule active = 0 alors.
'row(activecell;row).select
'selection.clearcontents[/I]
Workbooks(nom).Close False
End If
End Sub