Bonjour,
lorsque que je souhaite définir la feuille de mon range, j'obtiens une erreur au niveau de Set a et Set b.
Auriez-vous une solution ?
merci d'avance
Sub test()
Dim ws As Worksheet, wc As Worksheet
Dim nbsemaines As Integer
Dim Lastrow As Integer
Dim a As Range, b As Range
nbsemaines = Application.InputBox("Nombre de semaines") + 2
Set ws = ThisWorkbook.Sheets("TABBESOIN")
Set wc = ThisWorkbook.Sheets("Priorities")
Lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
Set a = ws.Range(Cells(1, 3), Cells(Lastrow, nbsemaines))
Set b = ws.Range(Cells(1, 1), Cells(Lastrow, 1))
Set criteria = wc.Range("A3")
Data1 = a.Address
Data2 = b.Address
crite = criteria.Address
wc.Range("AA3").Formula = "=sumproduct((" & Data2 & " = " & crite & ") *( " & Data1 & " ))"
End Sub